I have the following code in my page:
<asp:dropdownlist id="ddlCardExpYear" runat="server" class="p_smallest">
<% Dim x as Integer
For x = Year(Date()) To Year(Date()) + 10
%>
<asp:ListItem Value="<%=x%>"><%=x%></asp:ListItem>
</asp:dropdownlist>
When I try to run it I get the following error:
Parser Error Message: Code blocks are not supported in this context.
Can anyone tell me why? In classic asp, the above code is valid. How do I do the same in .net? Obviously I want the credit card year and month to be generated rather than hard coded (month maybe wouldn't be a problem, but years will change!)
<asp:dropdownlist id="ddlCardExpYear" runat="server" class="p_smallest">
<% Dim x as Integer
For x = Year(Date()) To Year(Date()) + 10
%>
<asp:ListItem Value="<%=x%>"><%=x%></asp:ListItem>
</asp:dropdownlist>
When I try to run it I get the following error:
Parser Error Message: Code blocks are not supported in this context.
Can anyone tell me why? In classic asp, the above code is valid. How do I do the same in .net? Obviously I want the credit card year and month to be generated rather than hard coded (month maybe wouldn't be a problem, but years will change!)