ASP.NET AJAX: another trick that might help in some specific scenarios
Today I've found another interesting post at the AJAX forums (yep, this is the only forum you can say I read frequently nowadays). The scenarios looks like this:
- a web app has a main page which is uses as the main entry page )lets call it page a)
- after clicking on a button, the user is redirected to page b through the Server.Transfer method. this is done so that the url doesn't change (at least that's what the guy said in the forums - interestingly, I've never seen this requirement before, but have seen the opposite quite often)
- page b has a page method that is called after a click
If you try to build 2 simple pages, you'll see that the page method call is broken in this scenario. why? simple: the call will be made over page a by default. Can you solve this easily? Yes. How? you just need to remember that page method calls are really similar to web service method calls. After you "get" this, you'll see that your job is really easy: just get a reference to the webrequesmanager client object and handle the invokingrequest event. from within that method, you just need to correct the url to the right page. btw, here's the link to the forum where you can see some client code that performs the operations i've mentioned.