6

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?

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
natiz
  • 563
  • 1
  • 15
  • 29

3 Answers3

8

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.

parliament
  • 21,544
  • 38
  • 148
  • 238
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.

Brian Mains
  • 50,520
  • 35
  • 148
  • 257
  • it will work, but i wanted to specify which form is used (using different names..).. – natiz Dec 02 '10 at 16:15
  • Well, just inside the form, you could place a server-side panel and use the panel as the means to identify the form... or there are other techniques. If you mean different pages, a property in the page code-behind (with a custom page base class) can also do that for you. Not sure all the details so I'm trying to think ahead... – Brian Mains Dec 03 '10 at 13:18
0

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

Community
  • 1
  • 1
ncakmak
  • 4,014
  • 5
  • 20
  • 17