Hi Abdul,
Modified solution works by utilizing jQuery!
Please download yourself a copy of the most recent jQuery.js file here:
jquery-1.4.4.js[
^], move it to a folder of your choice in you web solution, make sure this folder gets uploaded (published) to your server and you may want to rename it. In my example below I used the latest version, but I renamed it to
jQuery.js.
Without having jQuery.js loaded there should have been an error when the script was executed. In IE there will usually be small "Warning sign" type of symbol in the lower left corner of the status bar. Double-clicking that symbol will give you the details of what actually went wrong.
<head>
...
<script type="text/javascript" src="../scripts/jquery.js"></script>
...
</head>
...
...
var comboBoxID = "<%= frmProvinceInYear.FindControl("ddlPrv").ClientID %>";
var elements = $("#" + comboBoxID + " input");
var val = undefined;
if(elements.length==1)
{
val = elements[0].value;
}
And voila! Variable val contains the text of the selected entry.
Modification:
This solution works with jQuery as it allows you to select elements that are ancestors of an element. The selector that is being constructed would be according to OP's example like this
"#<whatEverTheClientIDis> input"
and means essentially: Give me all HTML input tags that are children of the tag with the id
<whatEverTheClientIDis>. Since the $() function returns an array elements is indexed in my code.
Cheers,
Manfred