Click here to Skip to main content
15,909,953 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Posted

1 solution

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

EDIT
-------------
Sample code
C#
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;
}
 
Share this answer
 
v2
Comments
Computer Wiz99 29-Oct-13 10:21am    
Thanks thatraja. Can you show me an example please?
thatraja 29-Oct-13 10:27am    
Did you check the link in my answer? anyway check the updated answer
Computer Wiz99 29-Oct-13 10:35am    
Where you have "SomeValue1" and "SomeValue2", What should go there? I donn't understand or I'm lost somewhere. Where should this code go? Before the Submit Button or after?
thatraja 29-Oct-13 10:39am    
"SomeValue1" and "SomeValue2" are variables. I have declared those in the code. Based on your question, I told you to use TextChanged event.

:( I think you should start to learn C# & ASP.NET from deep for your own good.
Computer Wiz99 29-Oct-13 10:41am    
Ok, Thanks. :|

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900