469,909 Members | 1,740 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,909 developers. It's quick & easy.

GridView header column text getting html encoded

TS
I have a headerText for a header column that is "Page<br>Name". it puts a
<brto force a line break, but the < and get encoded to &lt; and &gt;
thus negating its effect as an html control and doesn't respect the line
break

I'm guessing this happens during render. What do i need to do to keep the
line break?
Jul 4 '07 #1
4 9090
have you tried Server.HtmlDecode("Page<br>Name")

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"TS" <ma**********@nospam.nospamwrote in message
news:uK**************@TK2MSFTNGP02.phx.gbl...
>I have a headerText for a header column that is "Page<br>Name". it puts a
<brto force a line break, but the < and get encoded to &lt; and &gt;
thus negating its effect as an html control and doesn't respect the line
break

I'm guessing this happens during render. What do i need to do to keep the
line break?


Jul 4 '07 #2
Hi TS,

As for the text in the GridView header column, how did you put in to it?
Statically or dynamically through databinding? I've tested put static test
<br/into TemplateField's HeaderTemplate and it can be displayed correctly
as linebreak. e.g.

==============
...................
<HeaderTemplate>
Page<br />Name
<hr />
Page&lt;br&gt;Name
</HeaderTemplate>

<ItemTemplate>
<%# Eval("description")%>
</ItemTemplate>
</asp:TemplateField>
</Columns>

</asp:GridView>
================

Also, based on the test, if the text is from databinding source and
displayed in TemplateField, since it does not htmlencode it bydefault,
<br/can also display correctly as linebreak.

Please feel free to let me know if there is anything I missed or if you
have any further concerns.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Jul 5 '07 #3

TS wrote:
I have a headerText for a header column that is "Page<br>Name". it puts a
<brto force a line break, but the < and get encoded to &lt; and &gt;
thus negating its effect as an html control and doesn't respect the line
break

I'm guessing this happens during render. What do i need to do to keep the
line break?
If you use BoundField then set HtmlEncode to false
<asp:BoundField DataField="..." HeaderText="Page<br>Name"
HtmlEncode="false"/>

Regards,
Mykola
http://marss.co.ua

Jul 5 '07 #4
TS
that worked. Thanks
"marss" <ma******@gmail.comwrote in message
news:11**********************@n2g2000hse.googlegro ups.com...
>
TS wrote:
I have a headerText for a header column that is "Page<br>Name". it puts
a
<brto force a line break, but the < and get encoded to &lt; and &gt;
thus negating its effect as an html control and doesn't respect the line
break

I'm guessing this happens during render. What do i need to do to keep
the
line break?

If you use BoundField then set HtmlEncode to false
<asp:BoundField DataField="..." HeaderText="Page<br>Name"
HtmlEncode="false"/>

Regards,
Mykola
http://marss.co.ua

Jul 5 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Hans Merkl | last post: by
2 posts views Thread by rufpirat | last post: by
7 posts views Thread by WayDownUnder | last post: by
5 posts views Thread by bbawa1 | last post: by
5 posts views Thread by =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.