Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
53
rated 0 times [  59] [ 6]  / answers: 1 / hits: 127924  / 12 Years ago, sun, may 6, 2012, 12:00:00

This is my script :



<%
if (TempData[Resultat] != null){
%>
<script type=text/javascript>
alert('<%: TempData[Resultat]%>');
</script>
<%
}
%>


In this case pop-up is shown before page loaded, but i want that's appear after page is fully loaded.
in Html it's looks like this :



<body onload=happycode() ;>


but i can't use it in MVC i got one master page for all my web application


More From » html

 Answers
15

If you can use jquery then you can put the alert inside the $(document).ready() function. it would look something like this:



<script>
$(document).ready(function(){
alert('<%: TempData[Resultat]%>');
});
</script>


To include jQuery, include the following in the <head> tag of your code:



<script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js></script>


Here's a quick example in jsFiddle: http://jsfiddle.net/ChaseWest/3AaAx/


[#85743] Saturday, May 5, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cullenmaxl

Total Points: 414
Total Questions: 112
Total Answers: 87

Location: United States Minor Outlying Island
Member since Sat, May 28, 2022
2 Years ago
;