一般人都会用<input type="submit" />来提交表单,这是最直接的方式.可有些人就是觉得用按钮提交感觉怪怪的(按钮形状是凸起的!我一个同学就是不爽这个).
于是就想啊用链接提交.下面是一个例子.
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< title > 无标题页 </ title >
</ head >
< body >
< form id ="form1" method ="post" action ="testForm.aspx" >
用户名: < input type ="text" id ="txtname" name ="txtname" />< br />
密 码: < input type ="password" id ="txtpwd" name ="txtpwd" />< br />
</ form >
< script > ...
function aaa()
...{
document.forms(0).submit();
//document.form1.submit();
}
</ script >
< a href ="#" onclick ="aaa()" > 提交 </ a >
</ body >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< title > 无标题页 </ title >
</ head >
< body >
< form id ="form1" method ="post" action ="testForm.aspx" >
用户名: < input type ="text" id ="txtname" name ="txtname" />< br />
密 码: < input type ="password" id ="txtpwd" name ="txtpwd" />< br />
</ form >
< script > ...
function aaa()
...{
document.forms(0).submit();
//document.form1.submit();
}
</ script >
< a href ="#" onclick ="aaa()" > 提交 </ a >
</ body >
//
这段代码写在page_load中
string name = Request.Form[ " txtname " ].ToString();
string password = Request.Form[ " txtpwd " ].ToString();
Response.Write( " 用户名: " + name + " 密码: " + password);
string name = Request.Form[ " txtname " ].ToString();
string password = Request.Form[ " txtpwd " ].ToString();
Response.Write( " 用户名: " + name + " 密码: " + password);