自动填充两个文本框 [英] Auto populate two textboxes

查看:113
本文介绍了自动填充两个文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题。如何根据另一个文本框自动填充两个文本框?示例:TextboxFirstName,TextboxLastName将根据TextboxEmail填充。因此,如果用户将其电子邮件地址输入TextBoxEmail,则TextboxFirstName和TextboxLastName将使用用户的名字和姓氏填充。有办法做到这一点吗?是这样,有人可以告诉我怎么做?

解决方案

在TextBoxEmail的TextChanged Event [ ^ ]



编辑

-------------

示例代码

<前lang =cs> protected void TextBox1_TextChanged( object sender,EventArgs e)
{
DataTable dt = SomeFunctionReturnsDataTable(TextBox1.Text);
string SomeValue1 =( string )dt.Rows [ 0 ] [ SomeValue1];
string SomeValue2 =( string )dt.Rows [ 0 ] [ SomeValue2];
TextboxFirstName.Text = SomeValue1;
TextboxLastName.Text = SomeValue2;
}


I have a question. How can I auto populate two textboxes depending on another textbox? Example: TextboxFirstName, TextboxLastName are to be populated depending on TextboxEmail. So if a user enters their email address into TextBoxEmail then TextboxFirstName and TextboxLastName will populate with the user's first name and last name. Is there a way of doing this? Is so, can someone show me how?

解决方案

Call the populate details in TextBoxEmail's TextChanged Event[^]

EDIT
-------------
Sample code

protected void TextBox1_TextChanged(object sender, EventArgs e)
{
   DataTable dt = SomeFunctionReturnsDataTable(TextBox1.Text);
   string SomeValue1 = (string) dt.Rows[0]["SomeValue1"];
   string SomeValue2 = (string) dt.Rows[0]["SomeValue2"];
   TextboxFirstName.Text = SomeValue1;
   TextboxLastName.Text = SomeValue2;
}


这篇关于自动填充两个文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆