欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

asp.net Textbox服务器控件

程序员文章站 2024-03-01 09:40:28
复制代码 代码如下:   
 &...

复制代码 代码如下:

<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 = "奇数";
                }
            }
        }
    }
}