<html> <head> <title>web form</title> </head> <body> <form runat="server"> <asp:TextBox runat="server" id="value1" /> + <asp:TextBox runat="server" id="value2" /> <asp:Button runat="server" Text=" = " OnClick="Add" /> <asp:Label runat="server" id="result" /> </form> </body> </html> <script language="c#" runat="server"> void Add(object sender, EventArgs e) { if(value1.Text == "") value1.Text = "0"; if(value2.Text == "") value2.Text = "0"; try { result.Text = (int.Parse(value1.Text) + int.Parse(value2.Text)).ToString(); } catch { result.Text = "Error"; } } </script>
<html> <head> <title>web form</title> </head> <body> <form name="_ctl0" method="post" action="1.aspx" id="_ctl0"> <input type="hidden" name="__VIEWSTATE" value="dDwxOTE0NDY4ODE2Ozs+yeczcNbLHD6d7s7+Uue+wrxR/6I=" /> <input name="value1" type="text" id="value1" /> + <input name="value2" type="text" id="value2" /> <input type="submit" name="_ctl1" value=" = " /> <span id="result"></span> </form> </body> <html>
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18