views:

142

answers:

5

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"&gt;
  <input type="submit" value="submit" />
  <input ID="titleTB" type="text" />
  <input id="zipTB" type="text" /><br />
</form>
+4  A: 

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

Conrad
I am using (and want to use) plain forms, not ASP.NET forms! The ASP.NET code should "know" if it is a postback or not even if it is not an ASP.NET web form.
Olav
Unforunately Olav, ASP.NET requires some additional plumbing to support the webforms model. The only way this additional data will be sent to the webserver for processing as far as I know is if you set this attribute
Conrad
Add the runat attribute, turn off ViewState and EventValidation. It's as close as it gets. IsPostback is a server-side feature, you don't want to use a server-side form, so you can't use server-side features, either. Sorry.
Pawel Krakowiak
A: 

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 :-) ).

Gidon
+1  A: 

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.

Jakob Christensen
A: 

Something like 'POST' = Request.HTTPMETHOD

Olav
See my answer above. You can use if (Request.HttpMethod == "POST") ...
Jakob Christensen
A: 

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...

marcus.greasly