By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,870 Members | 1,212 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,870 IT Pros & Developers. It's quick & easy.

Control properties with entity references declared in ASPX get converted to character values

P: n/a
Group,

I have created a User Control with the property "Html" of type string.
If I declare this control on an ASPX page with the value "<b>This is an
entity: &lt;</b>" for the property "Html", the ASP.NET parser seems to
automatically convert the entity reference "&lt;" to it's corresponding
character value "<".

For example, if the tagprefix and tagname for the user control is "dn"
and "test":

<dn:test Html="<b>This is an entity: &lt;</b>" id="test" runat="server"
/>

.... this will result in a "Html" value of:

"<b>This is an entity: <</b>"

Why does this happen? It is quite annoying because I need to preserve
the entity reference. Is there any way to preserve entity references in
properties of type string when these are specified declaratively?

Thank you!

Feb 13 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
DWS
Jesl,
Take a look at the httpserverutility methods. htmlencode and htmldecode.
These two methods change string to from &lt to < etc.

http://msdn2.microsoft.com/en-us/lib...y_members.aspx
Good Luck
DWS


"je**@lundbeck.com" wrote:
Group,

I have created a User Control with the property "Html" of type string.
If I declare this control on an ASPX page with the value "<b>This is an
entity: <</b>" for the property "Html", the ASP.NET parser seems to
automatically convert the entity reference "<" to it's corresponding
character value "<".

For example, if the tagprefix and tagname for the user control is "dn"
and "test":

<dn:test Html="<b>This is an entity: <</b>" id="test" runat="server"
/>

.... this will result in a "Html" value of:

"<b>This is an entity: <</b>"

Why does this happen? It is quite annoying because I need to preserve
the entity reference. Is there any way to preserve entity references in
properties of type string when these are specified declaratively?

Thank you!

Feb 14 '06 #2

P: n/a
Thank you, but the problem is that the entity refrences get converted
even before I can get hold of the string value. Remember: I am reading
a string property set declaratively in the ASPX. I suspect that the
problem is that it is the default TypeConverter for strings in the
ASP.NET framework that is the culprit. Any thoughts on that or how to
write an alternative TypeConverter that does not touch the string?

/jesper

Feb 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.