Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is my ASP code
XML
<select id="Manufacturer" name="Manufacturer" <asp:Literal ID='litManfDis' runat='server' />
                  Manufacturer:  <option>SELECT MANUFACTURER</option>
                    <asp:Literal ID="litManf" runat="server" />
                </select>

Here is how I fill my select options.
Dim strManaufacturer As String = Utilities.IsNull(Request.Form("Manufacturer"))

SQL
ds = dbnet.Manufacturers("select distinct I001001 from TESTDATA.VININDEX")
     For Each dr As DataRow In ds.Tables(0).Rows
       litManf.Text &= String.Format("<option{0}>{1}</option>", IIf(dr("I001001").ToString().Trim().Equals(strManaufacturer, StringComparison.InvariantCultureIgnoreCase), " selected=selected", String.Empty), System.Web.HttpUtility.HtmlEncode(dr("I001001").ToString().Trim()))
     Next

But I do not know how to get the selected value into a string.
Can anyone help me with this?
Posted
Comments
ZurdoDev 27-Feb-15 9:59am    
Which selected value? I don't understand.
sudevsu 27-Feb-15 10:03am    
selected value of this "Manufacturer". In ASP.NET if we use some ddl.selectedvalue to get selected value. But with this literals I cannot figure out how to get selected value
sudevsu 27-Feb-15 10:08am    
something like selectedindexchanged event of dropdown. Similary I want for this html select.
John C Rayan 27-Feb-15 11:03am    
I don't quite understand why you are doing the way you are doing it now. Can't you use ASP.NET control. what's the reason for you are doing it this way.
sudevsu 27-Feb-15 11:24am    
I cannot use ASP controls. Because this project was developed entirely with literals and they want it to be continued like this only.

1 solution

I would suggest to use javascript/jquery to update a hidden field in your HTML with the selected value on selected event then use it in your server side.
In javascript you can use like this
JavaScript
for (var i = 0; i  < document.getElementById("Manufacturer").options.length; i++) {
       if(select.options[i].selected ) {
 
Share this answer
 
v4
Comments
John C Rayan 27-Feb-15 11:50am    
Thanks CHill60 for tidying up the content. Thank you.
sudevsu 27-Feb-15 12:15pm    
Thank you

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