Is there anyway to determine if the page is called through an AJAX or a regular postback in the Page_Load method, kinda like you can determine if it is a postback or the initial request via the Page.IsPostBack property?
I hoped the Page.IsAsync could be used for this but it doesn't seem to work like I expected.
I think when an AJAX does a post back you cannot access any controls like Label's, buttons etc...so try accessing a label by going label.text, if it fails catch the Exception...not a good way to do it, but a cheaky option for a quick test.
if the button clicked or postback occur, the page.ispostback will be true.
if you are using ajax then the page.ispostback will be false.
this can differentiate those methods.
What you're after is ScriptManager.IsInAsyncPostBack.
Sathesh_pandian:
if the button clicked or postback occur, the page.ispostback will be true.
if you are using ajax then the page.ispostback will be false.
Test that.
You'll find that Page.IsPostBack is actually true during partial postbacks.
That's it. ScriptManager.IsInAsyncPostBack does the trick. Thank you.![]()
it will not work when we are using it for different page.
calling another page.
That's because that isn't a postback.
No comments:
Post a Comment