ASP.Net First inner form in Server Form doesn’t POST

<form runat="server" id="outer" >

  <form name="inner1" method="POST" action="http://www.somesite.com/page.php" >
    <input type="text" size="7" name="o" id="origin" value="london" ></input>
    <input type="submit" name="getDirectionsBtn" id="btnSubmit" value="Submit" />
    <input type="hidden" name="oo" value="p" />
  </form>

  <form name="inner2" method="POST" action="http://www.somesite.com/page.php" >
    <input type="text" size="7" name="o" id="origin" value="london" ></input>
    <input type="submit" name="getDirectionsBtn" id="btnSubmit" value="Submit" />
    <input type="hidden" name="oo" value="p" />
  </form>

  <form name="inner3" method="POST" action="http://www.somesite.com/page.php" >
    <input type="text" size="7" name="o" id="origin" value="london" ></input>
    <input type="submit" name="getDirectionsBtn" id="btnSubmit" value="Submit" />
    <input type="hidden" name="oo" value="p" />
  </form>
</form>

Second+ inner form work just fine but first one does nothing. No broken tags as far as I can see.

I require nested forms as they are POST to an external site and open in a blank window.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

The HTML specification does not allow nested forms.

You might well find that the opening tag of the first inner form is being ignored (depending on browser and standards mode), then your main <form> is being closed by the first inner forms closing tag, and then the subsequent forms are working “as expected”.

Method 2

Yep, the first question has to be why are you nesting your forms? This is probably what is confusing ASP.Net more than anything. If you remove the outer form does it work?


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x