How can I get the value in server side of selected
Loading
How can I get the value in server side of selected
Know the answer? Post it. Somebody with the same question will find it here.
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
Naimish MakwanaRank #324 · 7.7K reputationPosted Feb 28, 2023, 5:27 AM EST
Hello Geni,
In which you want the result? .NET webform, MVC or Windows Form?
Thanks
Naimish
Naimish MakwanaRank #324 · 7.7K reputationPosted Feb 28, 2023, 5:32 AM EST
If you want in Webform use below code:
//Assuming your dropdown is like below //In code behide file add below event protected void myDropDownList_SelectedIndexChanged(object sender, EventArgs e) { string selectedValue = myDropDownList.SelectedValue; // Do something with the selected value }Note that the
SelectedIndexChangedevent handler will only be called if theAutoPostBackproperty of theDropDownListis set totrue.Thanks
Naimish Makwana
Geni Lou121 reputationPosted Feb 28, 2023, 6:25 AM EST
Hi Naimish Makwana,
I want the result in .NET Webforms..
will this work on webform? because I will not use the
Naimish MakwanaRank #324 · 7.7K reputationPosted Feb 28, 2023, 6:32 AM EST
Hello Geni,
Try below:
JavaScript Python C++ Java protected void language_SelectedIndexChanged(object sender, EventArgs e) { string selectedValue = language.SelectedValue; // Do something with the selected value here }In this example,
languageis the ID of the dropdown list control on your webform. TheSelectedIndexChangedevent is wired up to this control using theOnSelectedIndexChangedattribute in the HTML markup, like this:Thanks
Naimish Makwana
Geni Lou121 reputationPosted Feb 28, 2023, 6:36 AM EST
Thanks Naimish Makwana
I wil apply this :-)