Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

In my _Layout.cshtm want to display TempData in a div. TempDatantaining messages like if i add a record i will set it as like:

C#
TempData["OperationStatus"] = "Record Added Successflly";


i can able to show it in layout like:

HTML
<div id="msg">@TempData["OperationStatus"]</div>


i want to refresh the div for every 30 second for other messages should show for 30 sec.
Posted
Updated 25-Jul-13 23:59pm
v2

Use jQuery setInterval function
@TempData["OperationStatus"]

JavaScript
$(document).ready(function(){
setInterval(
            function () {
                $('#msg').hide();
            },
            30000);
});

Hope this helps
 
Share this answer
 
v3
Comments
josh-jw 26-Jul-13 6:43am    
thanks for reply. how to fade the div, so that the message is will hide after some seconds.
Jameel VM 26-Jul-13 6:46am    
$('divId').fadeIn("slow");
josh-jw 26-Jul-13 7:01am    
is the div visibility is set to hidden for show every 30 sec?
Jameel VM 26-Jul-13 7:14am    
set the div to hide.$('divId').hide();
josh-jw 26-Jul-13 8:10am    
will you please update it in your solution
try this:-

XML
<script type="text/javascript">
var refresh = setInterval(
function ()
{
$('#divLoad').fadeIn("slow");
}, 30000); // refresh every 30 seconds

<body>
<div id="divLoad"> </div>
</body>

</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900