Textbox服务器控件 asp.net Textbox服务器控件

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

Textbox服务器控件 asp.net Textbox服务器控件

  2021-03-20 我要评论
想了解asp.net Textbox服务器控件的相关内容吗,在本文为您仔细讲解Textbox服务器控件的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点: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 = "奇数";
                }
            }
        }
    }
}

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们