版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/stu_20052369/article/details/86742016
方法一: 给每个form 添加一个隐藏的字段
<form id="form1" name="form1" action="form.aspx" method="post">
<div>
<input type="text" name="Username" id="Username" />
</div>
<div>
<input type="password" name="Password" id="Password" />
</div>
<input type="hidden" name="Action" id="Action" value="form1" />
<button type="button">submit</button>
</form>
<form id="form2" name="form2" action="form.aspx" method="post">
<div>
<input type="text" name="Username" id="Username2" />
</div>
<div>
<input type="password" name="Password" id="Password2" />
</div>
<input type="hidden" name="Action" id="Action2" value="form2" />
<button type="button">submit</button>
</form>
后台区分form的方法
string formName = Request.Form("Action");
if(formName =="form1")
{
// do something
}
else if(formName =="form2")
{
// do something
}
方法二: 使用get和post混合的方法:
<form id="form1" name="form1" action="form.aspx?action=form1" method="post">
<div>
<input type="text" name="Username" id="Username" />
</div>
<div>
<input type="password" name="Password" id="Password" />
</div>
<button type="button">submit</button>
</form>
<form id="form2" name="form2" action="form.aspx?action=form2" method="post">
<div>
<input type="text" name="Username" id="Username2" />
</div>
<div>
<input type="password" name="Password" id="Password2" />
</div>
<button type="button">submit</button>
</form>
后台区分form的方法
string formName = Request.QueryString("action");
//Request.Params("action");
if(formName =="form1")
{
// do something
}
else if(formName =="form2")
{
// do something
}