<inputtype="submit"value="审核通过"onclick='this.form.action="<%=Url.Action("Action1")%>/>
<inputtype="submit"value="审核不通过"onclick='this.form.action="<%=Url.Action("Action2")%> />
<inputtype="submit"value="返回"onclick='this.form.action="<%=Url.Action("Action3")%>" />
<input type="submit" value="审核通过" name="action" /> <input type="submit" value="审核不通过" name="action"/> <input type="submit" value="返回" name="action"/>
[HttpPost]
public ActionResult Index(string action /* 其它参数*/)
{
if (action=="审核通过")
{
//
}
else if (action=="审核不通过")
{
//
}
else
{
//
}
}
[HttpPost]
[MultiButton("action1")]
public ActionResult Action1()
{
//
return View();
}
[HttpPost]
[MultiButton("action2")]
public ActionResult Action2()
{
//
return View();
}
<input type="submit" value="审核通过" name="action1" /> <input type="submit" value="审核不通过" name="action2"/> <input type="submit" value="返回" name="action3"/>
public class MultiButtonAttribute : ActionNameSelectorAttribute
{
public string Name { get; set; }
public MultiButtonAttribute(string name)
{
this.Name = name;
}
public override bool IsValidName(ControllerContext controllerContext,
string actionName, System.Reflection.MethodInfo methodInfo)
{
if (string.IsNullOrEmpty(this.Name))
{
return false;
}
return controllerContext.HttpContext.Request.Form.AllKeys.Contains(this.Name);
}
}
[HttpPost]
[MultiButton(Name = "delete", Argument = "id")]
public ActionResult Delete(string id)
{
var response = System.Web.HttpContext.Current.Response;
response.Write("Delete action was invoked with " + id);
return View();
}
<input type="submit" value="not important" name="delete" /> <input type="submit" value="not important" name="delete:id" />
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class MultiButtonAttribute : ActionNameSelectorAttribute
{
public string Name { get; set; }
public string Argument { get; set; }
public override bool IsValidName(ControllerContext controllerContext, string
actionName, MethodInfo methodInfo)
{
var key = ButtonKeyFrom(controllerContext);
var keyIsValid = IsValid(key);
if (keyIsValid)
{
UpdateValueProviderIn(controllerContext, ValueFrom(key));
}
return keyIsValid;
}
private string ButtonKeyFrom(ControllerContext controllerContext)
{
var keys = controllerContext.HttpContext.Request.Params.AllKeys;
return keys.FirstOrDefault(KeyStartsWithButtonName);
}
private static bool IsValid(string key)
{
return key != null;
}
private static string ValueFrom(string key)
{
var parts = key.Split(":".ToCharArray());
return parts.Length < 2 ? null : parts[1];
}
private void UpdateValueProviderIn(ControllerContext controllerContext,
string value)
{
if (string.IsNullOrEmpty(Argument)) return;
controllerContext.Controller.ValueProvider[Argument] = new ValueProviderResult
(value, value, null);
}
private bool KeyStartsWithButtonName(string key)
{
return key.StartsWith(Name, StringComparison.InvariantCultureIgnoreCase);
}
}
//如果是在MVC 2.0中的话,将UpdateValueProviderIn方法改为:
private void UpdateValueProviderIn(ControllerContext controllerContext, string value)
{
if (string.IsNullOrEmpty(Argument))
return;
controllerContext.RouteData.Values[this.Argument] = value;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有