Name attribute gets removed from FORM tag in .NET

2019-07-18 22:19发布

How do I make sure .NET does not remove the NAME attribute from my HTML forms. I require this in order to use AngularJS. Please let me know.

in visualstudio my form looks like this:

<form id="scheduleFrm" name="scheduleFrm" runat="server">

but it ends up looking like this in my browser's source:

<form id="scheduleFrm" method="POST"> without the name attribute

AngularJS needs the name attribute but name is available for my form

2条回答
你好瞎i
2楼-- · 2019-07-18 23:06

This is bad but it will get you going again:

<form id="theName" ...>
    <script>document.getElementById("theName").setAttribute("name", "theName");</script>
    <!-- ...formalities -->
</form>
查看更多
别忘想泡老子
3楼-- · 2019-07-18 23:08

There is an workaround. If you do for example:

$scope.scheduleFrm...

to access your form, so you can do:

var formName = $("#scheduleFrm").attr("name");
$scope[formName]...

to do the same.

查看更多
登录 后发表回答