Showing posts with label caused. Show all posts
Showing posts with label caused. Show all posts

Monday, March 26, 2012

Determine what element caused the Postback when handling the endRequest event

Hi All,

I have an UpdatePanel with 2 buttons. Pressing either of them causes a Postback and the panel gets refreshed.

I'm handling the endRequest event on the client side. Is there a way to determine which of the page elements caused the Postback?

Thanks,

Uzi

Try here:

http://www.eggheadcafe.com/articles/20050609.asp


Hi,

you can determine the postback element on the client side with the PageRequestManager. Attach to the beginRequest event and you can save the postback control. More information here:

http://ajax.asp.net/docs/ClientReference/Sys.WebForms/BeginRequestEventArgsClass/default.aspx

Regards
Marc André


Here is a neat way to get it done:

In the 'BeginRequest' event handler insert the postback element to the UserContext of the WebRequest:

function BeginRequestHandler(sender, args)

{

var elemName = args.get_postBackElement().id;var request = args.get_request();

request.set_userContext(elemName);

}

Then, when the request ends, at the 'EndEvent' get the information from the Response object:

function EndRequestHandler(sender, args)

{

var response = args.get_response();

alert(response._webRequest.get_userContext());

}

Thanks,

Uzi

Detailsview in UpdatePanel - Master$Content$dvParameters$ctl03 could not be located...

Hi,

I have this weird problem that just started to happen today and I have no idea what caused it:

I have a DetailsView bound to a SqlDataSource in an UpdatePanel. Whenever I edit something in the DetailsView and initiate the async postback, I get:

"An error has occurred because a control with id 'Master$Content$dvParameters$ctl03' could not be located or a different control is assigned the sameID after postback".

Any idea what could be wrong here?

Thanks,

Tom

Ok, I've found out that this happened because I accidentally changed the MasterPage ID in its OnLoad method rather than in the OnInit method