gpt4 book ai didi

ASP.NET MVC 2-设置Html.Form的ID

转载 作者:行者123 更新时间:2023-12-04 05:15:14 24 4
gpt4 key购买 nike

如何在ASP.NET MVC 2中设置Html.Form的ID?

我尝试了这个:

<% using (Html.BeginForm("Save", "Clients", new { id = "SubmitForm" })) {%>

但这不起作用,我的表单仍然没有id属性:
<form action="/TothSolutions/Secure/Clients/Save/SubmitForm" method="post"> 

我猜想这可以在ASP.NET MVC 1中工作,但不能在2中工作。我需要id属性集的原因是我可以对以下表单执行jQuery验证:$(“#myForm”)。validate等。

谢谢,
贾斯汀

最佳答案

您使用了错误的重载。使用这个:

http://msdn.microsoft.com/en-us/library/dd492714.aspx

using (Html.BeginForm("Save", "Clients", FormMethod.Post, 
new { id = "SubmitForm" }))

关于ASP.NET MVC 2-设置Html.Form的ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3029577/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com