469,363 Members | 2,640 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

& problem with hyperlink control

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.

Nov 19 '05 #1
6 4332
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.

Nov 19 '05 #2
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.

Nov 19 '05 #3
Tried in C# but got

Unrecognized escape sequence

Nov 19 '05 #4
I believe this is more of a C# problem than VB

Nov 19 '05 #5
In C#, this:
HyperLink1.NavigateUrl = "/test/test.ext?test1&test2";

Produced this:
http://localhost/test/test.ext?test1&test2

As expected.

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

"FoundThisOnline" wrote:
I believe this is more of a C# problem than VB

Nov 19 '05 #6
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!

Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Andy Breward | last post: by
1 post views Thread by D. Shane Fowlkes | last post: by
1 post views Thread by I am Sam | last post: by
reply views Thread by Seok Bee | last post: by
7 posts views Thread by Arpan | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.