C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




how to get htmldropdown list selected text


Posted Date: 05 Aug 2008      Total Responses: 3

Posted By: Santhosh       Member Level: Gold     Points: 1



Hi,
I am created one HTML DropDown in my asp.net i want to get that dropdown list text in C# How?
<select runat="server" onchange="chkEdu()" name="menu" id="ddlEducation" style="font-size: 8pt; font-family: Verdana">
<option selected>--Select--</option>
<option value='1'>Chennai</option>
<option value='2'>Hyderabad</option>
<option value='3'>Bangalore</option>
<option value='4'>Mumbai</option>
<option value='5'>Delhi</option>
</select>






Responses

Author: D.Jeya kumar(JK)    05 Aug 2008Member Level: DiamondRating:     Points: 3

Hi,

Please add the below event in you code bhind page.

protected void ddlEducation_ServerChange(object sender, EventArgs e)
{

}

Regards
JK



Author: UltimateRengan    05 Aug 2008Member Level: DiamondRating:     Points: 6

hi,

<script language ="javascript" type="text/javascript">
function GetTextBoxValues()
{
var ddl=document.getElementById("dropdown").value;
alert(ddl);
var e = document.getElementById("dropdown");
//var strText = e.options[e.selectedIndex].text;
//e.options[e.selectedIndex].style.color = "red"
var selected_text = e.options["2"].text;
if (selected_text=="c")
{
//Particular text will dispay with pink color
// e.options[e.selectedIndex].style.color = "red";
e.options["2"].style.color="red"
}
else
{
//selected text will display with RED Color
// e.options[e.selectedIndex].style.color="red";

}
}
</script>


<select id="dropdown" name="ddlcity" style="width: 289px">
<option value="ac">a</option>
<option value ="b">b</option>
<option value ="c">c</option>
<option value ="d">d</option>
</select>
  
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick ="GetTextBoxValues()" />
</form>


i hope this may help u

UltimateRengan
nathan.rengan@gmail.com
Trichy-Rider Group



Author: D.Jeya kumar(JK)    05 Aug 2008Member Level: DiamondRating:     Points: 3

if you want to access the Dropdown list in server side . add this onserverchange="ddlEducation_ServerChange" in <select > and

protected void ddlEducation_ServerChange(object sender, EventArgs e)
{
}

Regards
JK



Post Reply
You must Sign In to post a response.
Next : MySql
Previous : javascript function calling
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use