Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 asp.net 母版页中使用包含form control. 我无法弄清楚,正确的放置位置在哪里Html.BeginForm()。是它Layout Page还是View.
form control
Html.BeginForm()
Layout Page
View
谢谢您的帮助。
您应该在需要表格的任何一个位置放置一个。这通常意味着在视图内部,因为您希望在每个页面/表单上执行不同的操作,而不是在整个站点上执行相同的操作。
Webforms 在 MVC 中不存在每页一个表单的限制 - 每页可以有多个表单。
表单元素应该包含您的输入元素和文本区域。 因此,如果您的输入在您的布局或母版页中 - 您可以在那里有一个表单。 但大多数时候,您的表单都在您的视图中,您可以在其中创建或编辑数据。