zoukankan      html  css  js  c++  java
  • textbox填入后验证输入的合法或根据输入的内容失去焦点后立即得出其他信息

     <x:SimpleForm ID="SimpleForm1" runat="server" EnableBackgroundColor="true" ShowBorder="False"
                                    BodyPadding="2px" ShowHeader="False">
                                    <Items>
                                        <x:Panel ID="Panel3" ShowHeader="false" ShowBorder="false" EnableBackgroundColor="true"
                                            BodyPadding="2px" Layout="Column" runat="server">
                                            <Items>
                                            <x:Label ID="Label14" Width="90px" runat="server" ShowLabel="false" Text="教工号:" EncodeText="false"
                                                    CssClass="inline" ShowRedStar="true" >
                                                </x:Label>
                                                <x:TextBox ID="txtEmployeeNumber" runat="server" CssClass="mright" Required="true"
                                                    Width="200px" AutoPostBack="true" OnTextChanged="textChanged_Click">
                                                </x:TextBox>
                                                <x:Label ID="Label2" Width="90px" runat="server" ShowLabel="false" Text="姓名:" EncodeText="false"
                                                    CssClass="inline" ShowRedStar="true">
                                                </x:Label>
                                                <x:TextBox ID="txtName" runat="server" CssClass="mright" Required="true"
                                                    Width="200px">
                                                </x:TextBox>
                                                    </Items>
                                        </x:Panel>
                                       <x:Panel ID="Panel4" ShowHeader="false" ShowBorder="false" EnableBackgroundColor="true"
                                            BodyPadding="2px" Layout="Column" runat="server">
                                            <Items>
                                                <x:Label ID="Label6" Width="90px" runat="server" ShowLabel="false" Text="&nbsp性别:" EncodeText="false"
                                                    CssClass="inline" ShowRedStar="true">
                                                </x:Label>
                                                <x:RadioButton ID="rbtnNan" GroupName="MyRadioGroup1" Label=" " LabelSeparator="" Checked="true"
                                                    Width="105px" Text="男" runat="server">
                                                </x:RadioButton>
                                                <x:RadioButton ID="rbtnNv" GroupName="MyRadioGroup1" Label=" " LabelSeparator=""
                                                    Width="105px" Text="女" runat="server">
                                                </x:RadioButton>
                                                <x:Label ID="Label3" Width="90px" runat="server" ShowLabel="false" Text="出生日期:" EncodeText="false"
                                                    CssClass="inline" ShowRedStar="true">
                                                </x:Label>
                                                <x:DatePicker ID="txtBirthday" runat="server" DateFormatString="yyyy-MM-dd"  Required="true"
                                                    Width="200px">
                                                </x:DatePicker>
                                            </Items>
                                        </x:Panel>
                                        
                                        <x:Panel ID="Panel5" ShowHeader="false" ShowBorder="false" EnableBackgroundColor="true"  BodyPadding="2px"
                                            Layout="Column" runat="server">
                                            <Items>
                                                <x:Label ID="Label7" Width="90px" runat="server" ShowLabel="false" Text="身份证:" EncodeText="false"
                                                    CssClass="inline" ShowRedStar="true">
                                                </x:Label>
                                                <x:TextBox ID="txtIDCard" runat="server" CssClass="mright" Required="true" Width="200px" EmptyText="请输入18位的身份证号" RegexPattern="IDENTITY_CARD" RegexMessage="请输入正确的18位身份证号码" >
                                                </x:TextBox>
                                                <x:Label ID="Label9" Width="90px" runat="server" ShowLabel="false" Text="部门:" EncodeText="false"
                                                    CssClass="inline" ShowRedStar="true">
                                                </x:Label>
                                                <x:TextBox ID="txtPart" runat="server" CssClass="mright" Required="true"
                                                    Width="200px">
                                                </x:TextBox>
                                               
                                            </Items>
                                        </x:Panel>
                                    </Items>
                                </x:SimpleForm>
                            </Items>
                        </x:GroupPanel>
    

      根据输入的教工号填入后立即得出其他的信息,注意教工号txtEmployeeNumber控件后的

    OnTextChanged="textChanged_Click"
    后台代码:
      protected void textChanged_Click(object sender, EventArgs e)
            {
                if (txtEmployeeNumber.Text.Trim() != "")
                {
                    employeeBLL.GetEmployeeInfoByEmployeeNumber(txtEmployeeNumber.Text.Trim());
                    if (employeeBLL.GetEmployeeInfoByEmployeeNumber(txtEmployeeNumber.Text.Trim()) == null)
                    {
                        Alert.Show("对不起,你的信息还没有填入教师信息表,请联系管理员!", MessageBoxIcon.Error);
                    }
                    else
                    {
                        txtName.Text = employeeBLL.GetEmployeeInfoByEmployeeNumber(txtEmployeeNumber.Text.Trim()).Name;
                        txtPart.Text = employeeBLL.GetEmployeeInfoByEmployeeNumber(txtEmployeeNumber.Text.Trim()).Part;
                        txtIDCard.Text = employeeBLL.GetEmployeeInfoByEmployeeNumber(txtEmployeeNumber.Text.Trim()).IDcard;
                        txtBirthday.Text = employeeBLL.GetEmployeeInfoByEmployeeNumber(txtEmployeeNumber.Text.Trim()).Birthday.ToString("yyyy-MM-dd");
    
    
                    }
    
                }
            }
    

      

  • 相关阅读:
    linux /mac 下 go环境变量配置
    idea常用快捷键
    《Redis开发与运维》读书笔记
    【Zookeeper】windows环境下zookeeper安装
    【Linux命令】top命令
    【Linux命令】grep命令
    【Linux命令】ps命令
    【Java并发编程】23、ConcurrentHashMap原理分析(1.7和1.8版本对比)
    【Java深入研究】10、红黑树
    《大型网站技术架构 核心原理与案例分析》读书笔记
  • 原文地址:https://www.cnblogs.com/fang645421992/p/3829915.html
Copyright © 2011-2022 走看看