C# (ASP.Net) Linking selection values to constants in Codebehind

Posted by jasonvogel on Stack Overflow See other posts from Stack Overflow or by jasonvogel
Published on 2008-10-14T16:11:40Z Indexed on 2010/06/09 22:42 UTC
Read the original article Hit count: 190

Filed under:
|

ASPX Code

<asp:RadioButtonList ID="rbServer" runat="server" >
   <asp:ListItem Value=<%=ServerDeveloper%>> Developer </asp:ListItemv
   <asp:ListItem Value="dev.ahsvendor.com"> dev.test.com</asp:ListItem>
   <asp:ListItem Value="staging.ahsvendor.com"> staging.test.com</asp:ListItem>
</asp:RadioButtonList>

ASPX.CS - Codebehind

const string ServerDeveloper = "developer";

ASPX Error: Code blocks are not supported in this context.

Question: So what is the correct way to tie an dropdown/radio buttion/... ASPX value to a constant that is shared with the CodeBehind code?

I know that I could do rbServer.Add.Item("developer") [from the CodeBehind], but is there a way to achieve it from the Presentation side of things?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET