Ampersand in attribute

T

tfortney

I created an iframe HtmlGenericControl that has an ampersand in the "src"
attribute.....

Dim faxFrame As New HtmlGenericControl("iframe")
faxFrame.Attributes.Add("width", "100%")
faxFrame.Attributes.Add("height", "90%")
faxFrame.Attributes.Add("frameborder", "no")
faxFrame.Attributes.Add("src", "/archive/view.aspx?isPlugin=" & isPlugin &
"&iDoc=" & Server.UrlEncode(intDoc))


However when the control is rendered this is how it appears ...
<iframe width="100%" height="90%" frameborder="no"
src="/archive/view.aspx?isPlugin=false&amp;iDoc=document"></iframe>

It converts the ampersand in my querystring to the entity equiv of &amp;

Is there any way to make it preserve the ampersand... or is their any other
suggestions to accomplish the same thing?

Thanks
Tim Fortney
 
B

Bonj

I don't know whether this is right but try putting it as the literal to
start with.
i.e. if you put "abc&def" it might 'convert' this to "abc&amp;def"
but if you put "abc&amp;def" it might convert this right back to "abc&def" !
Sounds silly but try it...it might work
 
T

Tim Fortney

Yeah i have tried that...
i tried &&, the &, i tried server.urldecode/encode,
server.urlpathencode, etc....but no luck
 
M

Matt Berther

Hello Tim,

When the Attribute collection gets rendered, it runs through a Render method on the AttributeCollection, which in turn calls WriteAttribute on the HtmlTextWriter.

The WriteAttribute method on HtmlTextWriter calls HttpUtility.HtmlAttributeEncode, which in turn does the encoding.

The only way around it that I see would be to create a custom control, and override the Render method to output the attribute correctly.
 
T

tfortney

Well that is a bunch of poop!!
I was hoping i would not have to do that but all well

Thanks everyone with the input
Tim

Matt Berther said:
Hello Tim,

When the Attribute collection gets rendered, it runs through a Render
method on the AttributeCollection, which in turn calls WriteAttribute on the
HtmlTextWriter.
The WriteAttribute method on HtmlTextWriter calls
HttpUtility.HtmlAttributeEncode, which in turn does the encoding.
The only way around it that I see would be to create a custom control, and
override the Render method to output the attribute correctly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top