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

孤街醉人 提交于 2019-11-28 00:44:51

问题


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?


回答1:


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.




回答2:


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.




回答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



来源:https://stackoverflow.com/questions/4336867/asp-net-form-the-form-name-id-changes-to-aspnetform

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!