I am using temp data as follow in my controllers - very simple, when there is a problem:
TempData(\"StatusMessage\") = \"You have no items set to Auto-Ship.\
The sole purpose of TempData is to persist until the next request. Stuff you do not want to persist until the next request should go into ViewData, instead.
Realistically, this means that TempData is only safe to use when redirecting. When not redirecting, the "next request" could be anything.
would this be acceptable (removing the error once it has been shown):
<% If TempData.ContainsKey("ErrorMessage") Then %>
<script> $('div.error-container').show();</script>
<div class="msg-error"><p><%=TempData("ErrorMessage") %></p></div>
<%
TempData.Remove("ErrorMessage")
End If
%>