Reputation: 6413
Using: ASP.NET, C#, Javascript
I have a page which calls a javascript function on pageload which binds several events to elements. The page also contains an update panel. When an asynchronous postback is made the pageload function is called again and the events are binded. This has some undesireable consequences on the page and i was wondering if anyone could help me out.
Thanks in advance,
Shawn
Upvotes: 1
Views: 1329
Reputation: 436
For anyone else who ever comes across this problem, there is another solution. You can place the code in the Page_Load() function into a if(!Page.IsPostBack) statement. This will prevent any update panels from calling Page_Load() events on a partial page update.
Hope this will help,
Adam
Upvotes: 2
Reputation: 14619
The event has an args that tells you whether its a partial load:
function pageLoad(sender, args) {
if (!args.get_isPartialLoad()) {
// initial request
}
else {
// after async post
}
}
Upvotes: 2
Reputation: 6413
i found a workaround for this but its abit messy.
global variable.
var isPageLoaded = true;
function pageLoad()
{
if(isPageLoaded){
//do stuff here
}
}
Upvotes: 0