Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Control properties with entity references declared in ASPX get converted to character values

Reply
Thread Tools

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

 
 
jesl@lundbeck.com
Guest
Posts: n/a
 
      02-13-2006
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!

 
Reply With Quote
 
 
 
 
=?Utf-8?B?RFdT?=
Guest
Posts: n/a
 
      02-14-2006
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






"(E-Mail Removed)" 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!
>
>

 
Reply With Quote
 
 
 
 
jesl@lundbeck.com
Guest
Posts: n/a
 
      02-15-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Character reference or entity references? C Davis HTML 2 02-03-2009 05:27 PM
How to relate a SQL based entity with an Object based entity in Entity Framework markla ASP .Net 1 10-06-2008 09:42 AM
How can I get attribute values to not get converted from &apos; to ' or &amp; to & or &lt; to > ? Sammy XML 12 05-06-2005 10:14 PM
expanding character entity references in javascript Jim Higson Javascript 3 03-13-2005 02:15 AM
Character Entity References & DOM User Axes Dean Eyed Javascript 1 10-07-2004 10:25 AM



Advertisments