469,646 Members | 1,673 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Ampersand in attribute

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
Nov 18 '05 #1
4 3564
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

"tfortney" <tf******@pdgsi.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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

Nov 18 '05 #2
Yeah i have tried that...
i tried &&, the &, i tried server.urldecode/encode,
server.urlpathencode, etc....but no luck
"Bonj" <a@b.com> wrote in message
news:u8**************@TK2MSFTNGP11.phx.gbl...
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

"tfortney" <tf******@pdgsi.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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


Nov 18 '05 #3
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.
Yeah i have tried that...
i tried &&, the &, i tried server.urldecode/encode,
server.urlpathencode, etc....but no luck
"Bonj" <a@b.com> wrote in message
news:u8**************@TK2MSFTNGP11.phx.gbl...
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

"tfortney" <tf******@pdgsi.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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?


--
Matt Berther
http://www.mattberther.com
Nov 18 '05 #4
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" <mb******@hotmail.com> wrote in message
news:ud****************@TK2MSFTNGP10.phx.gbl...
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.
Yeah i have tried that...
i tried &&, the &, i tried server.urldecode/encode,
server.urlpathencode, etc....but no luck
"Bonj" <a@b.com> wrote in message
news:u8**************@TK2MSFTNGP11.phx.gbl...
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

"tfortney" <tf******@pdgsi.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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?


--
Matt Berther
http://www.mattberther.com

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Eidolon | last post: by
1 post views Thread by Dave | last post: by
12 posts views Thread by ~~~ .NET Ed ~~~ | last post: by
1 post views Thread by klynn | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.