textbox填入后验证输入的合法或根据输入的内容失去焦点后立即得出其他信息
2014-07-07 16:19
330 查看
<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=" 性别:" 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"); } } }
相关文章推荐
- Win8 在TextBox中设置提示信息,当TextBox获得焦点时消失,失去时验证
- ASP.NET 根据TextBox输入的内容自动定位到ListBox中项
- C语言身份证信息查询系统(可验证输入身份证是否合法)【已会】
- WPF 如何对TextBox中输入的内容进行验证?
- 利用反射实现ASP.NET控件和数据实体之间的双向绑定,并且在客户端自动验证输入的内容是否合法
- 验证标题是否存在(TextBox控件失去焦点验证)
- Ajax站内容搜索根据输入内容提示商品信息
- 判断TextBox输入的内容是否含有字母,若含有其他内容则抛出自定义异常
- 密码框失去焦点且为空时显示汉字“密码”、获取焦点时输入内容显示为密码“**********”的实现方法
- 根据验证结果js设置输入焦点(focus)
- ASP.NET(C#)中返回textbox焦点并全选所输入的内容
- 文本框内默认提示————请输入用户姓名(字体灰色),要求: (1)当文本框获得焦点时,默认提示消失 (2)当文本框失去焦点时,如果没有输入新内容,那么则显示原来的灰色字体内容; 如果有新内容输入则判断,如果长度小于10,则提示“姓名长度应该大于10个字符”
- [ASP.NET-VII] ASP.NET 使用验证控件(RegularExpressionValidator)验证输入(TextBox)中的输入是否合法
- Winform TextBox 验证输入的数字格式是否合法
- WPF,textBox默认是失去焦点绑定值才改变,怎么做到输入框值一改变就改变绑定值. Text="{Binding EvaluationContent,UpdateSourceTrigger=PropertyChanged}"
- popupWindow焦点问题以及实现根据输入内容筛选列表功能
- <<锋利的jQuery>>样例改进利用, html文本输入框得到与失去输入焦点的提示信息显示切换函数
- IOS用正则表达式验证textfield输入的内容是否合法
- IOS用正则表达式验证textfield输入的内容是否合法
- 输入框失去焦点时对输入信息进行JS验证