具有多个不同提交按钮的 MVC 剃刀表单? [英] MVC razor form with multiple different submit buttons?
本文介绍了具有多个不同提交按钮的 MVC 剃刀表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一个 Razor 视图在一个表单中有 3 个按钮.所有按钮的操作都需要表单值,这些值基本上是来自输入字段的值.
A Razor view has 3 buttons inside a form. All button's actions will need form values which are basically values coming input fields.
每次我单击任何按钮时,它都会将我重定向到默认操作.您能否指导我如何根据按钮按下将表单提交到不同的操作?
Every time I click any of buttons it redirected me to default action. Can you please guide how I can submit form to different actions based on button press ?
非常感谢您的时间、指导和帮助.
I really appreciate your time, guidance and help.
推荐答案
你也可以试试这个:
<input type="submit" name="submitbutton1" value="submit1" />
<input type="submit" name="submitbutton2" value="submit2" />
然后在您的默认函数中调用您想要的函数:
Then in your default function you call the functions you want:
if( Request.Form["submitbutton1"] != null)
{
// Code for function 1
}
else if(Request.Form["submitButton2"] != null )
{
// code for function 2
}
这篇关于具有多个不同提交按钮的 MVC 剃刀表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文