Snapper
Snapper

Reputation: 686

Get selected option server side

I'm getting a list of values on server side and I'm creating a dropdownlist with this:

var sb = new StringBuilder();
sb.Append("<select name=\"topics\" class=\"topicsSelect\" id=\"topicsSelect\">");
foreach (var topic in sorted){
sb.AppendFormat("<option value='{0}'>1{1}</option>", LinkManager.GetItemUrl(topic),
                                (topic.Fields["PageTitle"] != null && !string.IsNullOrEmpty(topic.Fields["PageTitle"].Value))
                                    ? topic.Fields["PageTitle"].Value
                                    : topic.Name);
            }

            sb.Append("</select>");
            litTopicList.Text = sb.ToString();

But now I'm trying to get the selected value onclick and I can't access this information? Am I missing something?

Thanks in advance.

Cheers

Upvotes: 0

Views: 944

Answers (2)

Claudio Redi
Claudio Redi

Reputation: 68400

Try with

string topicsSelect = Page.Request.Form["topicsSelect"];

or just

string topicsSelect = Page.Request["topicsSelect"];

Upvotes: 1

Related Questions