Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Dear ALl,


I am using master page on default.aspx . There is a script function on default page.
I want to call it on default page body load.

how ?
Posted
Comments
Gideon van Dyk 3-Feb-15 0:19am    
Are you trying to execute a function defined in the Master from the content page (default.aspx)?
Amit Vasi 3-Feb-15 0:21am    
no..
function is defined on default page. but i am using master page on it.
there is no onload event on content page. how to call that function on default page load
Sergey Alexandrovich Kryukov 3-Feb-15 0:27am    
You don't call bodyunload, especially not in "aspx" (not on server side). Browser calls it, and you are providing a handler. Inversion of control...
—SA
Amit Vasi 3-Feb-15 0:31am    
then how can i call that function ?
Please see my answer.

Just use jQuery document.ready() like...
XML
<script type="text/javascript">
    $(document).ready(function () {
       // some local script logic here
    });
</script>

Make sure to link jQuery file on the page.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 3-Feb-15 2:38am    
That's correct, a 5, but the inquirer misses much more elementary notion; I cannot expect this answer will be properly understood.
—SA
Thanks Sergey. :)

I hope OP understands. Let's see what he replies here. I will try my best to follow up and let him understand this. :)
Amit Vasi 3-Feb-15 3:59am    
here is my function that is using for close modalpopup with esc key.


function pageLoad(sender, args) {
if (!args.get_isPartialLoad()) {
$addHandler(document, "keydown", onKeyDown);
}
}

function onKeyDown(e) {
if (e && e.keyCode == Sys.UI.Key.esc) {
$find('Panel1_ModalPopupExtender').hide();
}
}



how these function will work..

if i am not using master page on default page then by using body onload="return pageload()" works..
but in case of master page it is not working...
I believe there is no need to add this event to the onload property. Remove that, it should work, as you are already using Ajax.

Amit Vasi 3-Feb-15 5:38am    
how i will call ? please suggest me.
You can UUe..
$(document).on("pageload",function(){
  alert("pageload event fired!");
});


Ref.
http://www.w3schools.com/jquerymobile/event_pageload.asp[^]
http://api.jquery.com/load/[^]
http://api.jquery.com/ready/[^]
 
Share this answer
 
Comments
/\jmot 4-Feb-15 2:46am    
ohhooo...Someone really down vote my answer.
please, somebody tell me whats my mistake??

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