Anchor as a Submit button

Posted by griegs on Stack Overflow See other posts from Stack Overflow or by griegs
Published on 2010-04-21T23:52:29Z Indexed on 2010/04/22 0:03 UTC
Read the original article Hit count: 277

Filed under:

I have an MVC 2 application that has the following on it;

    <% using( Html.BeginForm("Results","Quote", FormMethod.Post, new { name="Results" })){ %>
        <% Html.RenderPartial("Needs", Model.needs); %>
        <div class="But green" style="">
            <a href="." onclick="javascript:document.Results.submit();">Go</a>
        </div>
        <input type="submit" />
    <%} %>

Pressing the Submit button or the anchor both post back to the right ActionResult.

However, when in the controller I return View(stuff..) only the Submit button will come back to the page.

When the call finishes from pressing the anchor, I go to an error page informing me that the resource cannot be found.

I suspect it has something to do with href="." but am unsure what to set it to.

© Stack Overflow or respective owner

Related posts about asp.net-mvc