views:

23

answers:

2

Hello,

I'm using ASP.NET 3.5. I have a page in which i want to display a list in a formatted way:

<asp:RadioButtonList runat="server" ID="Options">
    <asp:ListItem Text="Yes.<br /><span>Detailed info.</span>" />
    <asp:ListItem Text="No.<br /><span>Detailed info.</span>" />
</asp:RadioButtonList>

Now the somewhat obvious problem with this is that i can't post this control to the server, because it will detect that the code contains potentially dangerous code (the html code inside the text property of the list items).
An alternative would be not to use a server control for this list, but i need that data on the server-side code, so i would prefer to keep it as a server control.
From my point of view, i don't need to validate this specific control because none of that data will be persisted in any way, and none of that data interacts with any part of my application.
On the other hand, i do want to keep the ValidateRequest functionality for the rest of the page, so i can't just set

<%@ Page ValidateRequest="false" ...

Question:

Is there any way to display data in such a way without getting this error?
Or is there any way in which i could disable the request validation feature only for that specific control? Something like

<myLibrary:myUserControl ValidateRequest="false" ...
A: 

Hey,

You could try multiple RadioButton controls, with no text in the control, and put the HTML content next to the control. You can group them by specifying the GroupName property.

You can only disable validation for an entire page, as its a page checking feature.

Brian
+1  A: 

Don't disable request validation. Just change your RadioButtonList:

<asp:RadioButtonList ID="Options" runat="server">
    <asp:ListItem Value="Yes">Yes<br /><span>Detailed Info</span></asp:ListItem>
    <asp:ListItem Value="No">No<br /><span>Detailed Info</span></asp:ListItem>
</asp:RadioButtonList>
matt-dot-net