Using HTML forms in ASP.NET MVC?

It seems that everything that I look at this topic has either changed since the release, or is very different from each other.

I just want to create a simple form in my opinion.

Should I use the Html.BeginForm () / TextBox () / EndForm () methods, or should I use the HTML form of a simple jane? Which is preferable?

This is what I have so far:

<%=Html.BeginForm("Create", "Product", FormMethod.Post); %>  
    <%=Html.TextBox("productTextBox", "Enter a shoe name"); %>  
    <input type="submit" name="createButton" value="Create Me!" />    
<%=Html.EndForm(); %>  

What is the “right” way to create a simple form using a button and text field in ASP.NET MVC and allow me to submit form data to / Product / Create?

How do I access form data from this method? Some people seem to use "FormCollection", while others just use the Request.Form method. Which way to use?

Can someone enlighten me?

+3
3

, , , URL- ( Global.asax). , , URL .

, "<form> " , , Html.Form( ). , "Url.Action", URL- . :

<form action="<%= Url.Action("Create") %>">

, Binder. ScottGu.

+5

. , .

+1

You looked at this:

http://weblogs.asp.net/scottgu/archive/2009/03/10/free-asp-net-mvc-ebook-tutorial.aspx

This is from the mouth of the horse and is updated with the final release.

+1
source

Source: https://habr.com/ru/post/1706099/


All Articles