I want to run a fadeIn when a C# object is not null. I would imagine that the particulars shouldn’t matter, but just in case its asp.net MVC 3 – razor.
jQuery
<script type="text/javascript">
function MessageFadeIn(){
$('messageLbl').fadeIn('slow', function () {
//Animation complete
});
}
</script>
ASP.NET
@if (ViewBag.Message != null)
{
//run jquery to fade this label in below...the label shouldnt display unless jQuery runs
<label id="messageLbl" style="background-color:Red;color:White;">@ViewBag.Message</label>
}
How can I accomplish this?
The messageLbl only exists if they message is not null so it will work.
jQuery does not throw an error if you try to fadeIn on a non existant object. It just fails gracefully.