$('#').change(function() { $('#').val($(this).val()); }); protected void DDL_SelectedIndexChanged(object sender, EventArgs e) { var selectedValue = ((DropDownList)sender).SelectedValue; TextBox1.Text = selectedValue; }$('#').change(function() { $('#').val($(this).val()); }); protected void DDL_SelectedIndexChanged(object sender, EventArgs e) { var selectedValue = ((DropDownList)sender).SelectedValue; TextBox1.Text = selectedValue; }Know the answer? Post it. Somebody with the same question will find it here.
DataTextField="VideoName" DataValueField="MaId" AutoPostBack="true" Width="130px" Height="25px" AppendDataBoundItems="true" OnSelectedIndexChanged="selectForTextBox">
*
runat="server" ValidationGroup="click2" InitialValue="Select Lecture" SetFocusOnError="true" />
SelectCommand="SELECT [MaId], [VideoName] FROM [Material] ">
Code behind
protected void selectForTextBox(object sender, EventArgs e)
{
var selectvalue = ((DropDownList)sender).SelectedValue;
TextBox1.Text = selectvalue;
}
Also I tried this javascript code
function select() {
var textbox = document.getElementById('<%=TextBox1.ClientID%>');
var parLab = document.getElementById('<%=DropDownList1.ClientID%>').option[document.getElementById('<%=DropDownList1.ClientID%>').selectedIndex].text;
if (parlab != 'Select Lecture') {
textbox.value = parlab;
} else {
textbox.value = '';
}
}
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Praveen SreeramRank #134 · 16.8K reputationPosted Jul 3, 2016, 9:17 PM EDT
- Are you having both the codes that you have mentioned in your page?
- is the AutoPostBack property of the dropdown is set to true?
If your answer is yes for both of my Questions above, then the client side script will not work.Dharmesh SinghRank #1,207 · 1.5K reputationPosted Jul 3, 2016, 7:35 PM EDT