13

Starting from ASP.NET MVC Preview 3, HTML.Button ( and other related HTML controls) are no longer supported.

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.

4 Answers 4

13

Just write <input type="button" ... /> into your html. There's nothing special at all with the html controls.

Sign up to request clarification or add additional context in comments.

1 Comment

11

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>

3 Comments

You don't need the <% that's asp.net forms. Use razor so value="@Model.UpVotes" don't be using the old <% %> use Razor.
Why? As far as I can see it is personal preference whether to use Razor or WebForms syntax. Both are supported and if a team is already using one and it is working fine for them then they should probably stick with it. You shouldn't just dismiss something because it is "old". (Incidentally, the original question, and this answer, were posted in 2008 - Before razor came to ASP.NET MVC)
It's personal preference, but it's the wrong personal preference
4

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.

Comments

-12

<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)

1 Comment

Not useful, the question was about ASP.NET MVC, not Web Forms.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.