Saturday, March 10, 2012

XmlHttpRequest and Page_Load question

If the target of your XmlHttpRequest is an aspx page then definitely Page_Load will get called and executed.
So you have to explicitly target an element in your page to prevent the page from being loaded again?

hello.

you use the xmlhttprequest object to get a resource from the server side. if teh resource you're getting is an asp.net page, then that page will go through it's normal life cycle (which means that that page will have its load event generated). you must keep in mind that we're referring to the page you're trying to get. the page that makes the call won't have its load event called.


JohanNL:

So you have to explicitly target an element in your page to prevent the page from being loaded again?

You can not skip Page_Load if target of your XmlHttpRequest is ASP.NET page. Try to call a Web-Service Method if you want only a perticular lines of code tobe executed on XmlHttpRequest.


hello.

just to add that what madesh said is also true for page methods.


For my better understanding.

When I update only the value of a label-control on a webpage via XmlHttpRequest (the page does not flicker).

Does it go through the Page_Load?


Johan, how are you updating the label? Are you using the XMLHttpRequest object directly? Or are you using ASP.NET AJAX? If so, are you using an UpdatePanel? Or are you calling a web service?

Aha, if you do not use ASP.NET AJAX, then one can change html by using javascript.

When using ASP.NET AJAX it always goes throug Page_Load.

No comments:

Post a Comment