It seems the page has not yet figured out its postback mode in the Page_Init event. It is always false, even when it is true in the Page_Load event.
I need to know if the page is being posted back or not in the Page_Init event. What is the most reliable way to determine this? I am currently interpreting "Page.Request.Form.Count > 0" as "IsPostBack = true" and it is working. Is that the best way? I don't want to use a session value, and obviously viewstate is not loaded yet.
![]() |
0 |
![]() |
I'm wondering if you are looking for simply
Page.IsPostBack
You mention that at the bottom, so I'm not sure what you are looking for if not that.
Peter Kellner
http://73rdstreet.com and blogging at
http://PeterKellner.net
MVP, ASP.NET
![]() |
0 |
![]() |
Hello,
I think you can try the following two method
1.
protected void Page_Init(object sender, EventArgs e)
{
if (Page.IsPostBack)
Response.Write("post back");
}2.
protected void Page_Init(object sender, EventArgs e)
{
NameValueCollection value = this.DeterminePostBackMode();if (value != null)
{
Response.Write("post back");
}
}hope it helps,
Jessica
Jessica Cao
Sincerely,
Microsoft Online Community Support
“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
![]() |
0 |
![]() |
What I am saying is Page.IsPostBack is always false during Page_Init. It seems it is being set between the page's OnInit and OnLoad events.
I will try this.DeterminePostBackMode() and see how that works.
![]() |
0 |
![]() |
veloearl:
What I am saying is Page.IsPostBack is always false during Page_Init. It seems it is being set between the page's OnInit and OnLoad events.
But I test it, and it works. Which means when the page posts back, it is true.
Jessica
Jessica Cao
Sincerely,
Microsoft Online Community Support
“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
![]() |
0 |
![]() |
Is there any chance you do NOT have the Ajax extensions installed? I wonder if the Ajax extensions change the way the IsPostBack property is handled.
![]() |
0 |
![]() |
Is there any chance you do NOT have the Ajax extensions installed? I wonder if installing the Ajax extensions changes the way the IsPostBack property is handled on a web server.
![]() |
0 |
![]() |
veloearl:
Is there any chance you do NOT have the Ajax extensions installed? I wonder if installing the Ajax extensions changes the way the IsPostBack property is handled on a web server.
Oh yeah, I don't have Ajax extensions installed and my page works.
Do you have any Ajax control on the web form when you test the IsPostBack during the Page_Init event?
Jessica
Jessica Cao
Sincerely,
Microsoft Online Community Support
“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
![]() |
0 |
![]() |
No Ajax on the page or in the project, but installing the extensions resulted in modified dlls and such...I would bet that is what is up. I wish there was a way to confirm...
![]() |
0 |
![]() |
Hi,
Just now, I downloaded the ASP.NET Ajax extensions(ASP.NET AJAX V1.0) and installed, but I am sorry to tell you that the IsPostBack works. Maybe you should try to reinstall it again.
Jessica
Jessica Cao
Sincerely,
Microsoft Online Community Support
“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
![]() |
0 |
![]() |
Hmmm, OK. Thanks for your help.
![]() |
0 |
![]() |