views:

205

answers:

2

How come my button refuses to do a postback in my super small learning ASP.Net MVC 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>

~/Controllers/BlogController.cs

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

I don't get it, what am I missing? :o

+6  A: 

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

Ray Vernagus
/facepalm Now I'm embarrassed :( But thanks :)
blueblood
We all do it! Glad to help. =)
Ray Vernagus
+3  A: 

Try:

<input type="submit" value="Post!" />
mc2thaH