Click here to Skip to main content
15,921,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to raise an event in javascript when a pageload occurs ?


How to Replace the below code in javscript?

code:
C#
protected void Page_Load(object sender, EventArgs e)
       {

SQL
if (!IsPostBack)
            {

}
}
Posted
Updated 30-Jan-14 23:29pm
v2

try this jquery function in head tag:-
XML
<script type="text/javascript">
$(document).ready(function () {
            alert("in page load");
        });
</script>
 
Share this answer
 
XML
<body onload="script();">

Or
HTML
document.onload = function ...

Or
HTML
window.onload = function ...

you could use jquery and use $(document).ready($("#myform).submit();) or you could wait for the ready then have a timer in your javascript just to wait a few extra seconds.
 
Share this answer
 
v2
Comments
Member 10517120 31-Jan-14 5:39am    
How about this ?


window.onload = isPostBack;

function isPostBack() {

if (!document.getElementById('clientSideIsPostBack')) {
return false;
}

if (document.getElementById('clientSideIsPostBack').value == 'Y') {

***// DO ALL POST BACK RELATED WORK HERE***

return true;
}
else {

***// DO ALL INITIAL LOAD RELATED WORK HERE***

return false;
}
}
Member 10517120 31-Jan-14 5:39am    
thanks for ur concern

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