views:

344

answers:

2

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

A: 

i found a workaround for this but its abit messy.

global variable.

var isPageLoaded = true;

function pageLoad()
{

if(isPageLoaded){

//do stuff here
}
}
ErnieStings
+1  A: 

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
    }
}
InfinitiesLoop