Click here to Skip to main content
14,302,251 members
Rate this:
Please Sign up or sign in to vote.
See more:

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:
//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;

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.
Updated 19-Feb-12 9:27am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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 AJAX control toolkit on website may be helpful to you[^]

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

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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100