Tutorial :How do I know if a regular for is a postback in ASP.ENT (was Why is IsPostback not set in ASP.NET plain forms)


I am using ASP.NET to process plain forms, posting back to myself. (I dont want to use ASP.NET forms, with runat="server )

To IsPostBack is not set when it really has to be a postback.

What is the reason for this?

Should I not post back to myself?

<form method="post" id="theForm" action="http://localhost/index.aspx">    <input type="submit" value="submit" />    <input ID="titleTB" type="text" />    <input id="zipTB" type="text" /><br />  </form>  


If you do not want to use runat="server", you can always use other methods such as Request.HttpMethod, which will be set to "POST" when using postbacks.


You'll need to set the runat='server' attribute for postbacks to work correctly for your form and controls.

Actually Olav, if you really want absolute control over the HTML and its processing i suggest you take a look at ASP.NET MVC that was designed with this in mind


Like Conrad said... you can't have the goods of both worlds. IsPostback is part of WebForms functionality, and webforms comes together with the runat="server" tag, (and some viewstate, eventvalidation tag, long dom id's :-) ).


Something like 'POST' = Request.HTTPMETHOD


Whilst you can't use IsPostback without having the asp.net goodness on your page, you might be able to look at the http header variable REFERRER - this tells you where the request came from - if it's your page then it was probably a postback...

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »