asp.net Textbox服务器控件
更新时间:2013年09月09日 14:55:55 作者:
这篇文章介绍了asp.net Textbox服务器控件的简单实例,有需要的朋友可以参考一下
复制代码 代码如下:
<body>
<form id="form1" runat="server">
<div>
姓名:<asp:TextBox ID="txtUser" runat="server"></asp:TextBox>
<br />
<br />
性别:<asp:RadioButtonList ID="rblsex" runat="server">
<asp:ListItem>男</asp:ListItem>
<asp:ListItem>女</asp:ListItem>
</asp:RadioButtonList>
密码:<asp:TextBox ID="txtPwd" runat="server" TextMode="Password"></asp:TextBox>
<br />
移动电话:<asp:TextBox ID="txttel" runat="server"
ontextchanged="TextBox3_TextChanged"></asp:TextBox>
<br />
简介:<br />
<asp:TextBox ID="txtinfo" runat="server"></asp:TextBox>
<br />
<br />
<asp:ImageButton ID="ImageButton1" runat="server" Height="58px"
ImageUrl="~/img/QQ截图20130909140346.png" Width="72px" />
<br />
<br />
<br />
<br />
<br />
</div>
</form>
</body>
textChange的事件代码如下:
复制代码 代码如下:
protected void txtNum2_TextChanged(object sender, EventArgs e)
{
if (txtNum2.Text.Length == 0)
{
//Page.RegisterClientScriptBlock("","<script>alert('请输入一个数');</script>");
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('请输入一个数');</script>");
txtNum2.Focus();
}
else
{
int result;
bool n1 = Information.IsNumeric(txtNum2.Text.Trim());
if (n1)
{
result = int.Parse(txtNum2.Text.Trim()) % 2;
if (result == 0)
{
txtSum.Text = "偶数";
}
else
{
txtSum.Text = "奇数";
}
}
}
}
}
您可能感兴趣的文章:
相关文章
Asp.net TextBox的TextChanged事件使用介绍
动态创建的控件是如何加载视图状态,还提到ProcessPostData方法的调用,这里我就用TextBox的TextChanged事件来说说视图数据的加载以及事件的触发2012-12-12
SQLServer 在Visual Studio的2种连接方法
这篇文章介绍了SQLServer 在Visual Studio的2种连接方法,有需要的朋友可以参考一下2013-09-09
aspnet core使用websocket实时更新商品信息的方法
这篇文章主要介绍了aspnetcore使用websocket实时更新商品信息,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧2024-01-01


最新评论