ASP.NET Form – The form nameid changes to aspnetForm

I have this code:

<form Name="AddPlace" ID="AddPlace" action="AddPlace.aspx" class="niceform" method="post" runat="server">

That when i try to execute the code i get this instead:
<form name="aspnetForm" method="post" action="AddPlace.aspx" id="aspnetForm" class="niceform">

How come it changes?

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

Set “clientidmode” attribute to “static” on the form tag to prevent the framework from override your name/id with “aspnetForm”. This was driving me nuts for hours.

Method 2

ASP.NET web forms takes control over the form element; for instance, if you try to change the action, ASP.NET will ignore it and change it back… why do you need a specific ID? Why won’t aspnetForm work?

HTH.

Method 3

It may be because you are using Master Pages. You can change the Action attribute dynamically if you really need to:

How to change Action attribute of the aspnetForm on MasterPage dynamically


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
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x