Html Form inside ASP.Net page causes no postbacks

I needed to re-design an existing asp.net page to include new html, created by third party designer.
After I’ve done the changes, I found that postbacks are not working.
It took me a while to understand that the cause of the problem is an html form, included in the main ASP.Net form like the following:

  <form method=”post” action=”about/subscribe/” id=”Mail”><input type=”text” value=”Enter your email address” name=”mail” class=”field-subscribe”/>

<input type=”image” align=”middle” class=”field-go” src=”Images/button_goheader.gif” value=”Go”/>

</form>

Note that buttons before html form are sending postbacks correctly, but those that are after the form in the html, are broken.  

So I  removed form, but  posted field to external URL  using PostBackUrl property:

 <asp:ImageButton ImageUrl=”~/Images/button_goheader.gif” PostBackUrl=”about/subscribe/” runat=”server” ToolTip=””Go“” align=”middle” class=”field-go” />

As an option, html form can be put into separate page and inserted into IFRAME on the main asp.net form.

Advertisements