Monday, June 3, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
192
rated 0 times [  199] [ 7]  / answers: 1 / hits: 62797  / 13 Years ago, tue, march 6, 2012, 12:00:00

I have a page that contains a user control within an update panel. $(document).ready(function() ) { is called and executes the code correctly when the page firsts loads but if the user clicks a button (within the user control), the document.ready() doesn't get called (document.load, onload also don't work)



I have researched this on the net and found similar problems but nothing that can explain why this isn't working. What other causes can there be for document.ready not working?


More From » c#

 Answers
9

This will be a problem with partial postback. The DOM isn't reloaded and so the document ready function won't be hit again. You need to assign a partial postback handler in JavaScript like so...



function doSomething() {
//whatever you want to do on partial postback
}

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(doSomething);


The above call to add_endRequest should be placed in the JavaScript which is executed when the page first loads.


[#87027] Monday, March 5, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mitchell

Total Points: 95
Total Questions: 110
Total Answers: 87

Location: Gabon
Member since Thu, Jul 15, 2021
3 Years ago
mitchell questions
;