Button will not be returned

Why does my button refuse to postback in my very small ASP.Net MVC tutorial application?

~ / Blog / Post.aspx

<h2>Post</h2>
<fieldset>
<legend>Blog message</legend>
<%using (Html.BeginForm())
  { %>
    <p>
        <label for="EntryTitle">Title:</label><br />
        <%= Html.TextBox("EntryTitle") %>
    </p>
    <p>
        <label for="EntryMessage">Message:</label><br />
        <%= Html.TextArea("EntryMessage") %>
    </p>
    <p>
        <input type="button" value="Post!" />
    </p>        
<%} %>
</fieldset>

<strong> ~ / Controllers / BlogController.cs

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Post(FormCollection collection)
    {            
        return View();
    }

I don’t understand what I am missing ?: Oh

+3
source share
2 answers

Change type="button"to type="submit".

+8
source

Try:

<input type="submit" value="Post!" />
+3
source

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


All Articles