asp.net Textbox服务器控件

这篇文章介绍了asp.net Textbox服务器控件的简单实例,有需要的朋友可以参考一下

复制代码 代码如下:


<body>
    <form runat="server">
    <div>

        姓名:<asp:TextBox runat="server"></asp:TextBox>
        <br />
        <br />
        性别:<asp:RadioButtonList runat="server">
            <asp:ListItem>男</asp:ListItem>
            <asp:ListItem>女</asp:ListItem>
        </asp:RadioButtonList>
        密码:<asp:TextBox runat="server" TextMode="Password"></asp:TextBox>
        <br />
        移动电话:<asp:TextBox runat="server"
            ontextchanged="TextBox3_TextChanged"></asp:TextBox>
        <br />
        简介:<br />
        <asp:TextBox runat="server"></asp:TextBox>
        <br />
        <br />
        <asp:ImageButton runat="server"
            ImageUrl="~/img/QQ截图20130909140346.png" />
        <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 = "奇数";
                }
            }
        }
    }
}

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjgzpf.html