& problem with hyperlink control

Discussion in 'ASP .Net' started by FoundThisOnline, Oct 11, 2005.

  1. I have been searching online for a whole day and couldn't find an
    answer for this. I have this hyperlink server control:

    ------------------------------------------------
    <asp:HyperLink ID="hylForms" Runat="server"
    NavigateUrl="#">Forms</asp:HyperLink>

    Codebehind:

    protected HyperLink hylForms;

    hylForms.NavigateUrl = "?Dept=" + Request.QueryString["Dept"] +
    "&Sect=forms";
    ------------------------------------------------

    Very straight forward right? I think so too but when it renders the
    HTML the "&Sect" part turned into "&amp;Sect" and the whole link would
    be

    ?Dept=HR&amp;Sect=forms


    Thinks I have tried already:

    - Delete the dll and recomplie
    - Different server
    - Move all the code on the asp.net page and no codebehind
    - Try different HTML characters (eg "<") that supposingly will render
    as well but only "&" will turn into "&amp;"


    Could someone give me a clue?

    Thanks in advance.
     
    FoundThisOnline, Oct 11, 2005
    #1
    1. Advertising

  2. In C# try
    \&

    In VB.Net try
    &&

    Just as a test once.

    --
    Curt Christianson
    site: http://www.darkfalz.com
    blog: http://blog.darkfalz.com



    "FoundThisOnline" wrote:

    > I have been searching online for a whole day and couldn't find an
    > answer for this. I have this hyperlink server control:
    >
    > ------------------------------------------------
    > <asp:HyperLink ID="hylForms" Runat="server"
    > NavigateUrl="#">Forms</asp:HyperLink>
    >
    > Codebehind:
    >
    > protected HyperLink hylForms;
    >
    > hylForms.NavigateUrl = "?Dept=" + Request.QueryString["Dept"] +
    > "&Sect=forms";
    > ------------------------------------------------
    >
    > Very straight forward right? I think so too but when it renders the
    > HTML the "&Sect" part turned into "&Sect" and the whole link would
    > be
    >
    > ?Dept=HR&Sect=forms
    >
    >
    > Thinks I have tried already:
    >
    > - Delete the dll and recomplie
    > - Different server
    > - Move all the code on the asp.net page and no codebehind
    > - Try different HTML characters (eg "<") that supposingly will render
    > as well but only "&" will turn into "&"
    >
    >
    > Could someone give me a clue?
    >
    > Thanks in advance.
    >
    >
     
    =?Utf-8?B?Q3VydF9DIFtNVlBd?=, Oct 11, 2005
    #2
    1. Advertising

  3. this:
    HyperLink1.NavigateUrl = "/test/test.ext?test&test2"

    produced this:
    http://localhost/test/test.ext?test&test2

    As expected (done in vb.net).

    --
    Curt Christianson
    site: http://www.darkfalz.com
    blog: http://blog.darkfalz.com



    "FoundThisOnline" wrote:

    > I have been searching online for a whole day and couldn't find an
    > answer for this. I have this hyperlink server control:
    >
    > ------------------------------------------------
    > <asp:HyperLink ID="hylForms" Runat="server"
    > NavigateUrl="#">Forms</asp:HyperLink>
    >
    > Codebehind:
    >
    > protected HyperLink hylForms;
    >
    > hylForms.NavigateUrl = "?Dept=" + Request.QueryString["Dept"] +
    > "&Sect=forms";
    > ------------------------------------------------
    >
    > Very straight forward right? I think so too but when it renders the
    > HTML the "&Sect" part turned into "&Sect" and the whole link would
    > be
    >
    > ?Dept=HR&Sect=forms
    >
    >
    > Thinks I have tried already:
    >
    > - Delete the dll and recomplie
    > - Different server
    > - Move all the code on the asp.net page and no codebehind
    > - Try different HTML characters (eg "<") that supposingly will render
    > as well but only "&" will turn into "&"
    >
    >
    > Could someone give me a clue?
    >
    > Thanks in advance.
    >
    >
     
    =?Utf-8?B?Q3VydF9DIFtNVlBd?=, Oct 11, 2005
    #3
  4. Tried in C# but got

    Unrecognized escape sequence
     
    FoundThisOnline, Oct 11, 2005
    #4
  5. I believe this is more of a C# problem than VB
     
    FoundThisOnline, Oct 11, 2005
    #5
  6. =?Utf-8?B?Q3VydF9DIFtNVlBd?=, Oct 11, 2005
    #6
  7. It's amazing how I found the solution now but not the entire day
    yesterday!

    Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");

    That will just take care of the problem!
     
    FoundThisOnline, Oct 11, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DC Gringo
    Replies:
    3
    Views:
    6,219
    mikeb
    Aug 19, 2004
  2. DC Gringo

    encoding of "&" vs "&amp;" in url

    DC Gringo, Aug 4, 2005, in forum: ASP .Net
    Replies:
    8
    Views:
    17,059
    davitz38
    Feb 5, 2010
  3. Replies:
    1
    Views:
    742
    Rosanne
    Oct 11, 2005
  4. Nathan Sokalski
    Replies:
    8
    Views:
    4,649
    Raymond
    Mar 1, 2006
  5. Versteijn

    TemplateColumn, HyperLink and &Amp

    Versteijn, Oct 20, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    114
    Versteijn
    Oct 20, 2004
Loading...

Share This Page