游走于ASP与ASP.NET的郁闷
网络整理 - 08-07
今天的问题是,关于在ASP.NET的环境下提交表单。我和ASP一样编写了一个按钮触发的事件,然后使用formname.submit来进行submit。结果提示:BC30451: Name ''form1'' is not declared.
但我在后面的表单里明明是定义了啊,源代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>index</title>
<script language="vb" runat="server">
sub bt_submit(sender AS Object,e As EventArgs)
form1.submit
end sub
sub bt_cancel(sender AS Object,e As EventArgs)
txt.text=""
txtpwd.text=""
txtpwd2.text=""
txtemail.text=""
end sub
</script>
</head>
<body>
<center>
<form name="form1" method="post" action="check.aspx" runat="server">
<table width="533" border="1">
<tr>
<th width="220" scope="row"><div align="right">ID:</div></th>
<td width="297"><asp:TextBox ID="txtid" runat="server" />
</td>
</tr>
<tr>
<th scope="row"><div align="right">Password:</div></th>
<td><asp:TextBox ID="txtpwd1" TextMode="Password" runat="server" Text=''12345678'' />
</td>
</tr>
<tr>
<th scope="row"><div align="right">input password again:</div></th>
<td><asp:TextBox ID="txtpwd2" TextMode="Password" runat="server" Text=''12345678'' />
</td>
</tr>
<tr>
<th scope="row"><div align="right">Sex:</div></th>
<td><asp:RadioButtonList ID="RadioButtonList" runat="server">
<asp:ListItem value="1">Men</asp:ListItem>
<asp:ListItem value="2">Female</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<th scope="row"><div align="right">e-Mail:</div></th>
<td><asp:TextBox ID="txtemail" runat="server" />
</td>
</tr>
<tr>
<th colspan="2" scope="row"><div align="center">
<asp:Button ID="btsubmit" runat="server"
Text="Submit"
BorderStyle="ridge"
BackColor="lightblue"
onmouseover="this.style.backgroundColor=''ff3366''"
onmouseout="this.style.backgroundColor=''lightblue''" />
<asp:Button ID="btcancel" runat="server"
Text="Cancel"
BorderStyle="ridge"
BackColor="lightblue"
onmouseover="this.style.backgroundColor=''ff3366''"
onmouseout="this.style.backgroundColor=''lightblue''" />
</div></th>
</tr>
</table>
</form>
</center>
</body>
</html>
看来ASP和ASP.NET之间真的是有太多的不同了,这样一来一回真是晕死。还得继续请教高人。毕竟——ASP.NET才是偶未来的方向,一定要很熟练的掌握!