我正在使用Hijaxing,我将有三个按钮: Prev、Add和Next。hijaxing可以同时使用Add和Next按钮。
上一个按钮设置为'onclick="history.back(-1)“‘。
Add按钮是由带有劫持Jquery的'(Html.BeginForm("Add","Home"))‘表单触发的,这很好用。
“下一步”按钮与“添加”按钮的作用相同。我想点击下一步按钮来点击控制器中的AcceptVerbs(HttpVerbs.Post)。有什么建议吗?
控制器...
[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" />
<% } %>发布于 2010-05-01 01:04:59
看起来你正在尝试让两个提交按钮调用不同的操作。
有关最佳方法,请参阅here。
https://stackoverflow.com/questions/2744725
复制相似问题