Why do nested forms in Asp.net mvc not have scope?

余生颓废 提交于 2019-12-25 03:12:02

问题


I have form that has several forms inside of it in asp.net mvc. The nested forms are using ajax helpers and are ajax forms.

The forms that are nested ALWAYS post to the original form's action, not their action.

Why? Why can't I have multiple forms on one page?


回答1:


You can have as many forms you like on a page, but you can't nest them.

It has nothing to do with ASP.NET or MVC, it's the HTML form tag that doesn't allow nesting. If you try to nest forms, the browser will ignore the inner form start tag.




回答2:


Even from the point of view of ASP.Net alone, only one form with a runat="server" attribute can be used within a web page. Otherwise, a run-time error will pop out halting the page creating process.



来源:https://stackoverflow.com/questions/4621597/why-do-nested-forms-in-asp-net-mvc-not-have-scope

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