Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Can any one help me out in the code for assign a dropdownlist box value to textbox .
Posted
Updated 6-Apr-17 16:52pm
Comments
nirmaljayamani 13-Jun-12 6:12am    
k thanks
tanweer 13-Jun-12 7:08am    
if this solves your issue then please rate the answer and close this thread by accepting the answer.

hi, using simple javascript this can be achieved like:
JavaScript
var e = document.getElementById("DropDownList");
var strText = e.options[e.selectedIndex].text;
document.getElementById('TextBox').value= strText; 

or using jQuery
JavaScript
$('#TextBox').val($("#DropDownList option:selected").text());
 
Share this answer
 
nirmaljayamani,

C#
///gets the dropdown's selected value in to textbox. 

 TextBox2.Text = DropDownList1.SelectedItem.Text;
 
Share this answer
 
Comments
Member 10594674 14-Feb-14 4:14am    
how to append second selected values to textbox from dropdown,,also preserve first selecteed value in textbox
Member 10594674 14-Feb-14 4:18am    
What I am working on is how I can add a value from a dropdown list to a text box. I want to add the value by selecting in dropdown how can it possible in asp.net c#?
Member 10927799 10-Jul-14 8:56am    
script is good..bt where to use this code.please send me full code.

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