textbox填入後驗證輸入的合法或根據輸入的內容失去焦點後立即得出其他資訊

來源:互聯網
上載者:User

標籤:blog   color   width   os   art   for   

 <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");                }            }        }

  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.