0

I am working with Hijaxing and I will have three buttons, Prev, Add, and Next. The hijaxing works with both the Add, and the Next button.

Prev button is set to 'onclick="history.back(-1)" '.
Add button is triggered by a '(Html.BeginForm("Add","Home"))' form with hijacking Jquery, which works fine.
Next button does does the same as the Add button. I would like the Next button to hit the [AcceptVerbs(HttpVerbs.Post)] in the Controller. Any suggestions?

CONTROLLER...

    [AcceptVerbs(HttpVerbs.Get)]
    public ActionResult Index()
    {
        return View();
    }

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Index(string home)
    {
        return RedirectToAction("Index", "Home");
    }

    public string GetQuote(Index index)
    {
        if (isNullorEmpty(index.name) != "")
            return "99";
        else
            return "Sorry";
    }

ASPX...

<script type="text/javascript">
    $(document).ready(function() {
        $("form[action$='GetQuote']").submit(function() {
            $.post($(this).attr("action"), $(this).serialize(), function(response) {
                $("#results").html(response);
            });
            return false;   
        });
    });    
</script>

    <%using (Html.BeginForm("GetQuote", "Stocks")) {%>
    <br />        
    <span id="results"></span>
    <br />
    <input id="txtSymbolName" name="name" type="text" />
    <br />        
    <input type="button" name="getPrev" value="Prev" onclick="history.back(-1)" />
    <input type="submit" value="Add" />          
    <input type="submit" name="home" value="Next" />
    <% } %>
MrM
  • 21,709
  • 30
  • 113
  • 139
  • I don't get your question/problem. Is your controller action not getting executed? What does the Next button being in the Form have to do with it? It should be in the form. Maybe tell us your intentions and it will help. – Jab Apr 30 '10 at 15:03
  • Sorry about that... see Edits – MrM Apr 30 '10 at 15:10

1 Answers1

3

It looks like you're trying to have 2 submit buttons call different actions.

See here for the best ways to do it.

Community
  • 1
  • 1
Lester
  • 4,243
  • 2
  • 27
  • 31