Ampersand in attribute

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tfortney

    Ampersand in attribute

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

    Dim faxFrame As New HtmlGenericCont rol("iframe")
    faxFrame.Attrib utes.Add("width ", "100%")
    faxFrame.Attrib utes.Add("heigh t", "90%")
    faxFrame.Attrib utes.Add("frame border", "no")
    faxFrame.Attrib utes.Add("src", "/archive/view.aspx?isPlu gin=" & isPlugin &
    "&iDoc=" & Server.UrlEncod e(intDoc))


    However when the control is rendered this is how it appears ...
    <iframe width="100%" height="90%" frameborder="no "
    src="/archive/view.aspx?isPlu gin=false&amp;i Doc=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


  • Bonj

    #2
    Re: Ampersand in attribute

    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;de f"
    but if you put "abc&amp;de f" it might convert this right back to "abc&def" !
    Sounds silly but try it...it might work

    "tfortney" <tfortney@pdgsi .com> wrote in message
    news:%23sz7bVHL EHA.1264@TK2MSF TNGP12.phx.gbl. ..[color=blue]
    > I created an iframe HtmlGenericCont rol that has an ampersand in the "src"
    > attribute.....
    >
    > Dim faxFrame As New HtmlGenericCont rol("iframe")
    > faxFrame.Attrib utes.Add("width ", "100%")
    > faxFrame.Attrib utes.Add("heigh t", "90%")
    > faxFrame.Attrib utes.Add("frame border", "no")
    > faxFrame.Attrib utes.Add("src", "/archive/view.aspx?isPlu gin=" & isPlugin &
    > "&iDoc=" & Server.UrlEncod e(intDoc))
    >
    >
    > However when the control is rendered this is how it appears ...
    > <iframe width="100%" height="90%" frameborder="no "
    > src="/archive/view.aspx?isPlu gin=false&amp;i Doc=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[/color]
    other[color=blue]
    > suggestions to accomplish the same thing?
    >
    > Thanks
    > Tim Fortney
    >
    >[/color]


    Comment

    • Tim Fortney

      #3
      Re: Ampersand in attribute

      Yeah i have tried that...
      i tried &&, the &#38;, i tried server.urldecod e/encode,
      server.urlpathe ncode, etc....but no luck


      "Bonj" <a@b.com> wrote in message
      news:u8bB1ZILEH A.3704@TK2MSFTN GP11.phx.gbl...[color=blue]
      > 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;de f"
      > but if you put "abc&amp;de f" it might convert this right back to "abc&def"[/color]
      ![color=blue]
      > Sounds silly but try it...it might work
      >
      > "tfortney" <tfortney@pdgsi .com> wrote in message
      > news:%23sz7bVHL EHA.1264@TK2MSF TNGP12.phx.gbl. ..[color=green]
      > > I created an iframe HtmlGenericCont rol that has an ampersand in the[/color][/color]
      "src"[color=blue][color=green]
      > > attribute.....
      > >
      > > Dim faxFrame As New HtmlGenericCont rol("iframe")
      > > faxFrame.Attrib utes.Add("width ", "100%")
      > > faxFrame.Attrib utes.Add("heigh t", "90%")
      > > faxFrame.Attrib utes.Add("frame border", "no")
      > > faxFrame.Attrib utes.Add("src", "/archive/view.aspx?isPlu gin=" & isPlugin[/color][/color]
      &[color=blue][color=green]
      > > "&iDoc=" & Server.UrlEncod e(intDoc))
      > >
      > >
      > > However when the control is rendered this is how it appears ...
      > > <iframe width="100%" height="90%" frameborder="no "
      > > src="/archive/view.aspx?isPlu gin=false&amp;i Doc=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[/color]
      > other[color=green]
      > > suggestions to accomplish the same thing?
      > >
      > > Thanks
      > > Tim Fortney
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Matt Berther

        #4
        Re: Ampersand in attribute

        Hello Tim,

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

        The WriteAttribute method on HtmlTextWriter calls HttpUtility.Htm lAttributeEncod e, 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.
        [color=blue]
        > Yeah i have tried that...
        > i tried &&, the &#38;, i tried server.urldecod e/encode,
        > server.urlpathe ncode, etc....but no luck
        > "Bonj" <a@b.com> wrote in message
        > news:u8bB1ZILEH A.3704@TK2MSFTN GP11.phx.gbl...[color=green]
        >> 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;de f"
        >> but if you put "abc&amp;de f" it might convert this right back to
        >> "abc&def"[/color]
        > !
        >[color=green]
        >> Sounds silly but try it...it might work
        >>
        >> "tfortney" <tfortney@pdgsi .com> wrote in message
        >> news:%23sz7bVHL EHA.1264@TK2MSF TNGP12.phx.gbl. ..[color=darkred]
        >>> I created an iframe HtmlGenericCont rol that has an ampersand in the
        >>>[/color][/color]
        > "src"
        >[color=green][color=darkred]
        >>> attribute.....
        >>>
        >>> Dim faxFrame As New HtmlGenericCont rol("iframe")
        >>> faxFrame.Attrib utes.Add("width ", "100%")
        >>> faxFrame.Attrib utes.Add("heigh t", "90%")
        >>> faxFrame.Attrib utes.Add("frame border", "no")
        >>> faxFrame.Attrib utes.Add("src", "/archive/view.aspx?isPlu gin=" &
        >>> isPlugin[/color][/color]
        > &
        >[color=green][color=darkred]
        >>> "&iDoc=" & Server.UrlEncod e(intDoc))
        >>>
        >>> However when the control is rendered this is how it appears ...
        >>> <iframe width="100%" height="90%" frameborder="no "
        >>> src="/archive/view.aspx?isPlu gin=false&amp;i Doc=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
        >>>[/color]
        >> other
        >>[color=darkred]
        >>> suggestions to accomplish the same thing?
        >>>[/color][/color][/color]

        --
        Matt Berther

        Comment

        • tfortney

          #5
          Re: Ampersand in attribute

          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" <mberther@hotma il.com> wrote in message
          news:udW%23SdML EHA.3664@TK2MSF TNGP10.phx.gbl. ..[color=blue]
          > Hello Tim,
          >
          > When the Attribute collection gets rendered, it runs through a Render[/color]
          method on the AttributeCollec tion, which in turn calls WriteAttribute on the
          HtmlTextWriter.[color=blue]
          >
          > The WriteAttribute method on HtmlTextWriter calls[/color]
          HttpUtility.Htm lAttributeEncod e, which in turn does the encoding.[color=blue]
          >
          > The only way around it that I see would be to create a custom control, and[/color]
          override the Render method to output the attribute correctly.[color=blue]
          >[color=green]
          > > Yeah i have tried that...
          > > i tried &&, the &#38;, i tried server.urldecod e/encode,
          > > server.urlpathe ncode, etc....but no luck
          > > "Bonj" <a@b.com> wrote in message
          > > news:u8bB1ZILEH A.3704@TK2MSFTN GP11.phx.gbl...[color=darkred]
          > >> 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;de f"
          > >> but if you put "abc&amp;de f" it might convert this right back to
          > >> "abc&def"[/color]
          > > !
          > >[color=darkred]
          > >> Sounds silly but try it...it might work
          > >>
          > >> "tfortney" <tfortney@pdgsi .com> wrote in message
          > >> news:%23sz7bVHL EHA.1264@TK2MSF TNGP12.phx.gbl. ..
          > >>> I created an iframe HtmlGenericCont rol that has an ampersand in the
          > >>>[/color]
          > > "src"
          > >[color=darkred]
          > >>> attribute.....
          > >>>
          > >>> Dim faxFrame As New HtmlGenericCont rol("iframe")
          > >>> faxFrame.Attrib utes.Add("width ", "100%")
          > >>> faxFrame.Attrib utes.Add("heigh t", "90%")
          > >>> faxFrame.Attrib utes.Add("frame border", "no")
          > >>> faxFrame.Attrib utes.Add("src", "/archive/view.aspx?isPlu gin=" &
          > >>> isPlugin[/color]
          > > &
          > >[color=darkred]
          > >>> "&iDoc=" & Server.UrlEncod e(intDoc))
          > >>>
          > >>> However when the control is rendered this is how it appears ...
          > >>> <iframe width="100%" height="90%" frameborder="no "
          > >>> src="/archive/view.aspx?isPlu gin=false&amp;i Doc=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?
          > >>>[/color][/color]
          >
          > --
          > Matt Berther
          > http://www.mattberther.com[/color]


          Comment

          Working...