Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在ASP标记中编写c#代码_C#_Asp.net - Fatal编程技术网

如何在ASP标记中编写c#代码

如何在ASP标记中编写c#代码,c#,asp.net,C#,Asp.net,我有这个代码,我有这个错误 在此上下文中不支持代码块 <% for (int i = 0; i < 5; i++) { %> <asp:DropDownList runat="server" ID="<%=i %>"> <asp:ListItem><%i.ToString(); %></asp:ListItem> </asp:DropDo

我有这个代码,我有这个错误 在此上下文中不支持代码块

  <%
        for (int i = 0; i < 5; i++)
        {
    %>
    <asp:DropDownList runat="server" ID="<%=i %>">
        <asp:ListItem><%i.ToString(); %></asp:ListItem>
    </asp:DropDownList>
    <%
        }            
    %>

您可以使用Razor来编写这样的代码。举个例子


这里还有一个在web表单中不允许的问题。

这个问题不是用asp.net mvc标记的,而是用asp.net标记的。正因为如此,你的答案是无效的。好吧,那么我将把它改写成“建议使用MVC3:”)你在使用ASP.NET MVC吗??