& problem with hyperlink control

  • Thread starter Thread starter FoundThisOnline
  • Start date Start date
F

FoundThisOnline

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.
 
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!
 
Back
Top