Showing posts with label endrequest. Show all posts
Showing posts with label endrequest. Show all posts

Wednesday, March 28, 2012

Different instances of beginRequest & endRequest for different UpdatePanels

Is it possible to assign a different beginRequest function or endRequest function for individual UpdatePanels on a page? It appears that usingSys.WebForms.PageRequestManager.getInstance().add_beginRequest( someFunction ) assign the function to all UpdatePanels on the page.

Thank you

yeah, check this out...

http://dotnetslackers.com/community/blogs/simoneb/archive/2006/11/19/ASP.NET-Ajax-UpdatePanelNotifier_3A00_-get-notified-of-partial-updates.aspx


i have looked into alittle more.

<script type="text/javascript" language="javascript">
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args)
{
var elem = args.get_postBackElement();
//What Triggered The Update
//alert(elem.id);
}
function EndRequestHandler(sender, args)
{
var s = args.get_response().get_responseData().split('|');
//UpdatePanel Triggered
alert(s[2]);
}
</script>


Thanks for the response. So there is currently no 'native' way do do this? Surprising. I'll check out this project.

Thanks again.


Interesting... It still would be nice to have a native way of assigning functions to different panels, but this could certainly be of use in certain circumstances.

Thanks!

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

Detecting which UpdatePanel was updated for endRequest

I've got an issue where I'm trying to execute some javascript when a specific UpdatePanel on my page (I have about 5) is updated. I've added event handlers for initializeRequest and endRequest. I know that I can get the ID of the element that *caused* the postback - but I really don't want that. I need the id of the UpdatePanel that is being updated.

Then endRequest method that gets called after an UpdatePanel gets updated is called for any and all UpdatePanels - this ambiguity makes it difficult to know which UpdatePanel caused this request.

Any ideas?

Cheers,

Bobby

The endRequest event doesn't have the information you want. If you handle the pageLoaded event, the args parameter that gets passed in to your handler has a panelsUpdated property which returns an array containing the panels that were updated.