I have a asp.net detailsview control on a page. I've noticed that it always displays the raw text from my database field, it doesn't interpret the html in the text -- so it displays < b>mytext< /b> instead of just mytext in bold.
Is there anyway to get the control to interpret the html in the data being returned
Regards melt
Can you post the code of your control? The basics are you need to set the HtmlEncode property to false. This is due to a difference in how labels and textboxes handle encoding, something meant to protect you from malicious scripts someone may have entered in these fields.
If you have it set to auto-generate fields (default), you'll need to change to BoundFields or TemplateFields instead and set the offending field's HtmlEncode Property to false.
You can see a code sample of the individual fields in MSDN, here's a simplified example:
<asp:DetailsView runat="server" AutoGenerateRows="False">
<Fields>
<asp:BoundField DataField="ProductName" HeaderText="Product" />
<asp:BoundField DataField="CategoryName" HeaderText="Category" />
<asp:BoundField DataField="HTMLField" HeaderText="HTML" HtmlEncode="false" />
</Fields>
</asp:DetailsView>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With