我正在使用Hijaxing,我将有三个按钮,Prev,Add和Next。 hijaxing既可以使用Add,也可以使用Next按钮。
上一个按钮设置为'onclick =“history.back(-1)”'
添加按钮由'(Html.BeginForm(“添加”,“主页”))'表单触发,劫持Jquery,工作正常。
下一步按钮与“添加”按钮的作用相同。我想在Next按钮中点击Controller中的[AcceptVerbs(HttpVerbs.Post)]。有什么建议?
... 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" />
<% } %>