Page_Init, IsPostBack is always false

Do you guys experience Page.IsPostBack is always false in Page_Init, but works correctly in Page_Load?  I posted such over in the ASP.NET forum, and they were all like, get serious.  I am wondering if installing the Ajax extensions modified the way that property is managed on a web server.  It is always false during OnInit.  I even built a sample page/project containing no Ajax, same behavior.  Again, it works beautifully in Page_Load.
4/10/2007 2:59:07 AM 9760 articles. 0 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 9

I try to simulate your problem using following code:


using System;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
	protected override void OnInit(EventArgs e)
		Write("OnInit: IsPostBack = " + IsPostBack);

	protected override void OnLoad(EventArgs e)
		Write("OnLoad: IsPostBack = " + IsPostBack);

	protected void Page_Load(object sender, EventArgs e)
		Write("Page_Load: IsPostBack = " + IsPostBack);

	protected void Page_Init(object sender, EventArgs e)
		Write("Page_Init: IsPostBack = " + IsPostBack);

	private void Write(string str)
		Response.Write(str + "<br>");

	protected void Button1_Click(object sender, EventArgs e)
		Write("Button click");

All works fine, and meets my expectations. The post back mode is determined in method DeterminePostBackMode, which can be overriden. The sequence is:

  1. DeterminePostBackMode
  2. OnInit
  3. OnLoad
  4. ....

Do you have DeterminePostBackMode method overriden in your code?

4/10/2007 11:16:10 AM

Similar Artilces:

Page_Init, IsPostBack always false
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. I'm wondering if you are looking for simply Page.IsPostBack  ...

Old AJAX in .NET 1.1 compatibility with .NET framework 2.0. Ajax does not work always ....................
Hello,I have converted the web site from .NET 1.1 to .NET 2.0. Some of the pages in the web site use AJAX which was developed in .NET 1.1Ajax does not work smoothly in .NET 2.0. Do I have to use ATLAS or is there any fix I can use to make the AJAX work ?Please let me know. Many thanks in advance. Nick..........

IsPostBack Is always false
Hi,Recently I made some changes to a site that was working fine. After these changes were made the Ispostback value is always false and this has mean't loss of events firing. After days of searching google I can't figure out what went wrong. The viewstate is enabled in the masterpage and web.config. What sort of debugging steps should I be taking to hunt down this problem as I can't pin point it to a specific change that I made and I am pretty sure the viewstate (or lack of it) is the problem . All help is much appreciate :)Increase your wine sales - Hi t...

Checkbox.Checked always false in Ajax
I have a checkbox In a Div in a table in a panel in an  UpdatePanel  I cannot read the value it always shows false even when tickedUpdatePanel     panel         table            div                Checkbox As a fix I made the div runat="server" and it is fine  why is this so, and is there a better solutionjnc Can you post the code as how you are reading the values? ThanksMark post(s) as "Answer&...

IsPostBack always set to false for screen refresh
When I refresh brower window (using refresh icon on the browser), I found out from running in VS Debugger that IsPostBack is set to false every time the screen is refreshed. I want to do some database initialization when when the page is displayed for the first time. Can someone please shed some light on this problem? Thanks, Amy Actually this is not a problem - refreshing the page is different than posting back. Post backs are caused by the controls you place on your form. If you tell us a little more about your page and what you're trying to do perhaps we can offer better...

System.Web.UI.Page and
 İ use .net 2005 and i use System.Web.UI.Page,my webpage is working.But in here we use other page that extends System.Web.UI.Page.if i extend my class to our  webpage my isn't  working. My error explanation is: sys.webfrom.pagerequestmanagerparserErrorException:the message received from the server could not beparsed.Common causes for this error are when the response is modifies by calls to Response.write(),response filters,httpmodules,or server trace is enabled. Details:Error parsing near'itle||Untitled PAge|<script language=J...

Does anyone know of either an blog available or an 'inline editor' for
Hey all:  I'm desperately trying to find an AJAX control (I don't care if it's currently for ASP.NET AJAX.NET, since if not, I'll do the conversion and make it available to others) for creating blogs and another inline editor control, so that if there is text on the page, I can click on the text and it will automatically display an editor and allow me to edit the text/html.  Does anyone know of a control like this that's AJAX enabled?  Especially AJAX.NET.  I'm only interested in open-source, since any improvements I make I will make available on Thanks in...

Web farm load balacing resulting in IsPostBack always == false?
Ok, got two web servers that are basically load balanced between. Application works just fine in single server environment. Also, if I'm lucky enough to post back to the same server in load balanced environemt everything also works fine. The problem starts when I end up posting back between servers. I've confirmed I am running the same .NET version, same exact application version, same machineKey settings, etc. on both ServerA and ServerB.Basically if you've done any research on this stuff before you know that the first thing the page stuffs in it's ViewState is the result of Page::GetT...

IsPostBack is correct in Debug Mode but always False at run time!
I was testing a very simple page with nothing but just a form and a button.  When run in debug mode, ie F5 from Visual Web Developer 2008 Express, IsPostBack seems to return the correct value whether it's the initial load (false) or when I have clicked the Submit button (true). But if I compile it and run it from the web, IsPostBack is always false! What have I done wrong?  The code is as follows: test.aspx<html xmlns=""><head runat="server"><title>Untitled Page</title></head><body>...

AJAX Asyncpost by ButtonField of Grid inside updatepanel set IsPostback to false
I have a Grid control inside the Updatepanel with ChildrenAsTrigger=true. Clicking the Grid's button field (RowEditing) causes async post back but in the Load event if I check the Page.IsPostback it gives false. While another Update panel's async post back sets Page.IsPostBack to true. The only difference in both update panels is the first one's post back caused by a Grid's button field and the second one's post back triggered by a drop down inside the update panel. Async post back for both are caused by controls inside same update panels. Please guide what I&...

Rich level UI Tool/Framework for Ajax enabled .net application
Hi All,  I want to use some rich level UI tool/framework in my ajax enabled .net application. Can anyone guide me which rich UI tool/framework will give more futures. I am looking for good look and feel , dynamic creation of client side control through ajax calls.Want to avoid hand written javascript code. Thnaks in advance. Selva Have you looked at the ASP.NET AJAX Control Toolkit? you ask a question, remember to click "mar...

ispostback is false even when it is not suppose to be false
I got this form with several panels and buttons to go back and forward. I initiate a variable inside the page_load, like this: <script runat="server"> dim s as integer sub page_load if not ispostback then    s=0 end if end sub </script> Somehow, whenever a forward button or previous button is clicked, it will execute s=0. I followed each step and it looks like ispostback is always false in this case. Any suggestions? Thanks. dim s as integer s is never given an initial value, so, it's default value is 0, even on a postback. Zath Where is it tha...

Starting an Application in .net
i am new to could any one give me simple ajax,net example so that i start building on my ajax skills please.........  I started with the todolist video on the main page, and its all you need to know to get started. Don't forget to click "Mark as Answer" on the post that helped you.This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.    ...

Does the AJAX Control Toolkit always use AJAX?
I have not seen this question answered anywhere yet, but does anyone know if the Control Toolkit always uses Async postbacks for all its operations. For instance the hovermenu or filteredtexbox, for example, should not need to do an async postback. As far as I can see the hover menu does not, but i could be wrong. Does anyone know if this is the case and if so do you know which controls do not postback? We don't have this information compiled anywhere, but it's generally simple enough to tell from having a look at the code. FilteredTextBox, for example, doesn't do any postbacks of any...

Web resources about - Page_Init, IsPostBack is always false -

The following error occurred: Exception of type 'System.Web.HttpUnhandledException' was thrown. System.NullReferenceException: Object reference ...

The following error occurred: Exception of type 'System.Web.HttpUnhandledException' was thrown. System.NullReferenceException: Object reference ...

The following error occurred: Exception of type 'System.Web.HttpUnhandledException' was thrown. System.NullReferenceException: Object reference ...

The following error occurred: Exception of type 'System.Web.HttpUnhandledException' was thrown. System.NullReferenceException: Object reference ...

The following error occurred: Exception of type 'System.Web.HttpUnhandledException' was thrown. System.NullReferenceException: Object reference ...

Resources last updated: 12/1/2015 9:57:25 AM