ASP.NET MVC 中的 HTML.Button
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/59267/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTML.Button in ASP.NET MVC
提问by Graviton
Starting from ASP.NET MVC Preview 3, HTML.Button ( and other related HTML controls) are no longer supported.
从 ASP.NET MVC Preview 3 开始,不再支持 HTML.Button(和其他相关的 HTML 控件)。
The question is, what is the equivalent for them? I've an app that was built using Preview 2, now I have to make it compatible with the latest CTP releases.
问题是,它们的等价物是什么?我有一个使用预览版 2 构建的应用程序,现在我必须使其与最新的 CTP 版本兼容。
采纳答案by Graviton
I figured it out. It goes something like this:
我想到了。它是这样的:
<form method="post" action="<%= Html.AttributeEncode(Url.Action("CastUpVote")) %>">
<input type="submit" value="<%=ViewData.Model.UpVotes%> up votes" />
</form>
回答by Joel Coehoorn
Just write <input type="button" ... />
into your html. There's nothing special at all with the html controls.
只需写入<input type="button" ... />
您的html。html 控件没有什么特别之处。
回答by Brad Wilson
Several of the extension methods got moved to Microsoft.Web.Mvc, which is the MVC Futures DLL. You might want to look there for things that have gone missing.
一些扩展方法已移至 Microsoft.Web.Mvc,即 MVC Futures DLL。您可能想在那里寻找丢失的东西。
回答by Thunder3
<asp:Button>
is the ASP.NET equivalent to the HTML.Button. It will by default generate an <input type="button">
. (This is the System.Web.UI.WebControls.Button class)
<asp:Button>
是等效于 HTML.Button 的 ASP.NET。默认情况下,它会生成一个<input type="button">
. (这是 System.Web.UI.WebControls.Button 类)