0
我創造在這裏使用MVC 5我有兩個按鈕確定被點擊了MVC的按鈕5
<div class="row">
<div class="col-sm-offset-5 col-sm-1">
<input type="submit" name="save" value="SAVE" class="btn btn-primary glyphicon glyphicon-save" />
</div>
<div class="col-sm-offset-0 col-sm-1">
<input type="submit" name="reset" id="reset" value="Reset" class="btn btn-warning active glyphicon glyphicon-refresh" />
</div>
</div>
和我有一個正在被點擊按鈕之後調用方法的Web應用程序,
現在對這一事件我想區分的按鈕點擊,
一樣,
如果用戶點擊
<input type="submit" name="save" value="SAVE" class="btn btn-primary glyphicon glyphicon-save" />
然後
{
//this code should run
}
,如果用戶點擊
<input type="submit" name="reset" id="reset" value="Reset" class="btn btn-warning active glyphicon glyphicon-refresh" />
然後
{ //this set of code should run }
,我的方法是這樣的
[HttpPost]
public ActionResult insertrecd(FormCollection fc)
{
if(fc["reset"]==null)
{
return RedirectToAction("party", "party");
}
else
{
ViewBag.message = string.Format("Hello {0}.\\nCurrent Date and Time: {1}", "name", DateTime.Now.ToString());
return RedirectToAction("party", "party");
}
}
我需要做什麼,我想對不同的按鈕點擊做不同的代碼?