4

I have this code and I have this error Code blocks are not supported in this context

  <%
        for (int i = 0; i < 5; i++)
        {
    %>
    <asp:DropDownList runat="server" ID="<%=i %>">
        <asp:ListItem><%i.ToString(); %></asp:ListItem>
    </asp:DropDownList>
    <%
        }            
    %>
1
  • Are you working on ASP.NET MVC?? Commented Dec 25, 2012 at 7:50

2 Answers 2

2

That's not allowed in web forms.

Sign up to request clarification or add additional context in comments.

Comments

2

You can use Razor, to write such code. Take a look here for example.

And here another blog entry

2 Comments

The question is not tagged with asp.net mvc, it's tagged with asp.net. Because of that, your answer is not valid.
Ok, then I`ll rephrase it into advise to use MVC3 :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.