We help IT Professionals succeed at work.

C#, webmatrix, <select>

panJames
panJames asked
on
Medium Priority
339 Views
Last Modified: 2012-05-12
Hello experts.

I am using WebMatrix and C#.


To populate <select> tag I use the following code:

 <select id="abc">
      @foreach (var p in itemsFromQuery)
      {
            counter=counter + 1;
            <option id="@counter">@p.Name</option>
      }
      
</select>

It works fine.

Two questions:

1. How can I determine the index of option selected by user?
2. How can dynamically set an option with a selected index?

Thank you

panJames
Comment
Watch Question

CERTIFIED EXPERT
Commented:

Explore More ContentExplore courses, solutions, and other research materials related to this topic.