Showing posts with label ajax. Show all posts
Showing posts with label ajax. Show all posts

Friday, March 19, 2010

how to find out what caused the postback

if you are using ajax panel to ajaxify yr web page, you might notice that postback happen for any trigger happens within the ajax panel, this includes date selection in the calendar, button click event and etc.

you might want to find out which control causes the postback to do yr code handling.

the key is to use string control = Request.Form["__EVENTTARGET"]; in page_load event.

The [control] will be null during page load, if the postback is caused by button1, [control] will have the value of button1.

Checkout this artcile to find out more

Wednesday, March 10, 2010

how to execute javascript after ajax request is completed

If you are using the microsoft ajax framework, you might encounter a scenario where you need to execute javascript after your ajax call is completed.

The key is to add your javascript method using

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

put the javascript method that you need to execute in EndRequestHandler function.

Checkout this very useful post.