ASP.NET Form - The form name\id changes to aspnetF

2019-01-25 14:28发布

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?

3条回答
Juvenile、少年°
2楼-- · 2019-01-25 14:38

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

查看更多
戒情不戒烟
3楼-- · 2019-01-25 14:41

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.

查看更多
The star\"
4楼-- · 2019-01-25 14:48

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.

查看更多
登录 后发表回答