Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have my code wherein I have used 2 TextBoxes , 2 Listboxes and a button.

textbox1 - First Name
textboox2- Last Name
listbox1 - Populated from Emp table in MS Access
listbox2 - Populated from Emp table in MS Access
Button1 - to fetch details of name entered and display on same page on some labels.

TextBox1 has a dropdownextender which is populated from ListBox1 and TextBox2 has a dropdownextender which is populated from ListBox2.

I did the javascript code and the selected value is now showing onto the respective textboxes as below:
C#
//In code behind..
ListBox1.Attributes.Add("onclick", "setText1(this.options[this.selectedIndex].value);");
            ListBox2.Attributes.Add("onclick", "setText2(this.options[this.selectedIndex].value);");

//In source code
function setText1(newValue) 
{
    document.getElementById("<%=txtbx_Firstname.ClientID %>").value = newValue;
}
function setText2(newValue1) 
{
    document.getElementById("<%=txtbx_Lastname.ClientID %>").value = newValue1;
}



Problem:
When I click the Button to fetch details of entered name, the textboxes gets cleared. due to this, I am not able to make a comparison between the textbox values and database values.

Please help how to retain the textbox values and use in my code.

My full page functionality depends on this.
Posted
Updated 19-Feb-12 9:27am
v2

1 solution

From the code it seems that you want the user to select the first name and last name values from the data available in database which is displayed in listboxes. I think combo box control may be suitable for this purpose and the following samples of ASP.net AJAX control toolkit on ASP.net website may be helpful to you

http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/ComboBox/ComboBox.aspx[^]

If your problem is solved, you may accept and vote the solution, otherwise please post your queries

PES
 
Share this answer
 
Comments
VivekSharma0925 20-Feb-12 0:00am    
Thanks for the answer but the functionality I am performing as you understood is only 1 part.

On the other part, I have to use the same textboxes with the user manually entering the names. So, in this case, I have to keep the listboxes disabled; which I have done.

In case, I can use combo box as just a textbox without the dropdown, it would be helpful; otherwise I have to use textboxes with listboxes and dropdownextenders only.

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