473,413 Members | 1,807 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

undesired behavior in setting hyperlink .NavigateURL property


in the codebehind portion of a page, I dynamically create a series of
hyperlinks that I add to the page.

in that code, I have something like this:

dim h as new hyperlink

h.NavigateURL = "/somepage.aspx?age=35&gender=M"
Unfortunately, when it renders the HTML page, it changes the ampersand in
the URL as follows

h.NavigateURL = "/somepage.aspx?age=35&gender=M"
This, of course, doesn't work, because the 2nd parameter's name has now been
changed from 'gender' to 'amp;gender'
How can I get around this?
(I tried setting the 'href' attribute directly ...
h.attributes.add("href","/somepage.aspx?age=35&gender=M") ... but it
produces the same result)


Nov 17 '05 #1
3 1915
you might look into HttpUtility.HtmlEncode("yourtext")

"Boban Dragojlovic" <news@_N_O_S_P_AM_dragojlovic.org> wrote in message
news:MX***************@newssvr14.news.prodigy.com. ..

in the codebehind portion of a page, I dynamically create a series of
hyperlinks that I add to the page.

in that code, I have something like this:

dim h as new hyperlink

h.NavigateURL = "/somepage.aspx?age=35&gender=M"
Unfortunately, when it renders the HTML page, it changes the ampersand in
the URL as follows

h.NavigateURL = "/somepage.aspx?age=35&amp;gender=M"
This, of course, doesn't work, because the 2nd parameter's name has now been changed from 'gender' to 'amp;gender'
How can I get around this?
(I tried setting the 'href' attribute directly ...
h.attributes.add("href","/somepage.aspx?age=35&gender=M") ... but it
produces the same result)

Nov 17 '05 #2
I am sorry I meant httputility.htmldecode("yourtext")

"vMike" <Mi************@nospam.gewarren.com.delete> wrote in message
news:bn**********@ngspool-d02.news.aol.com...
you might look into HttpUtility.HtmlEncode("yourtext")

"Boban Dragojlovic" <news@_N_O_S_P_AM_dragojlovic.org> wrote in message
news:MX***************@newssvr14.news.prodigy.com. ..

in the codebehind portion of a page, I dynamically create a series of
hyperlinks that I add to the page.

in that code, I have something like this:

dim h as new hyperlink

h.NavigateURL = "/somepage.aspx?age=35&gender=M"
Unfortunately, when it renders the HTML page, it changes the ampersand in the URL as follows

h.NavigateURL = "/somepage.aspx?age=35&amp;gender=M"
This, of course, doesn't work, because the 2nd parameter's name has now

been
changed from 'gender' to 'amp;gender'
How can I get around this?
(I tried setting the 'href' attribute directly ...
h.attributes.add("href","/somepage.aspx?age=35&gender=M") ... but it
produces the same result)


Nov 17 '05 #3
One more comment, the &amp; should not effect the url query string. It
should still work the same.
"Boban Dragojlovic" <news@_N_O_S_P_AM_dragojlovic.org> wrote in message
news:MX***************@newssvr14.news.prodigy.com. ..

in the codebehind portion of a page, I dynamically create a series of
hyperlinks that I add to the page.

in that code, I have something like this:

dim h as new hyperlink

h.NavigateURL = "/somepage.aspx?age=35&gender=M"
Unfortunately, when it renders the HTML page, it changes the ampersand in
the URL as follows

h.NavigateURL = "/somepage.aspx?age=35&amp;gender=M"
This, of course, doesn't work, because the 2nd parameter's name has now been changed from 'gender' to 'amp;gender'
How can I get around this?
(I tried setting the 'href' attribute directly ...
h.attributes.add("href","/somepage.aspx?age=35&gender=M") ... but it
produces the same result)

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nielsen | last post by:
Hi Question regarding Content Management Server and C# string survey = thisPosting.Placeholders.Datasource.RawContent.ToString() Label1.Text = survey Label1 shows correctly the value:...
4
by: Amir Eshterayeh | last post by:
Dear Friends My asp hyperlink goes to relative address instead of absolute. I like navigate url goes to outsite link like www.asp.net but now, it goes to www.mysite/www.asp.net please help....
0
by: Ryan Harvey | last post by:
Hi all, I have written a web user control that contains a repeater control. the ItemTemplate for this control is basically 6 Hyperlinks in a row, that are dynamically allocated one of 7 gif...
2
by: Jason | last post by:
I have a data grid with a hyperlink column. The hyperlink is created by a class that extracts the link from an XML Document. How can I populate the hyperlink column in the data grid with the...
10
by: david | last post by:
Hi, all: I need a help from you about DataGrid control. I created a DataGrid, dg, in design view of .NET visual Stadio and use the builder to add a Hyperlink column to dg. I want to try to assign...
3
by: VB Programmer | last post by:
I have a datalist with a hyperlink in the Item Template. When I set the NavigateUrl simply to this, the databound CategoryId shows up fine: <asp:HyperLink id=hlLink runat="server"...
2
by: Andy | last post by:
Hi, This is one of those things I thought should e easy... I'm programatically trying to set the navigateURL property in a hyperlink in the headertemplate of a repeater, but always get the...
8
by: Jeff | last post by:
ASP.NET 2.0 I'm wondering how to set the color of a visited HyperLinkField (the link text) in a GridView?? Here is the markup of the HyperLinkField I have problems with: <asp:HyperLinkField...
2
by: BobLaughland | last post by:
Hi There, I need a control on my site that is a hyperlink style control, but it must, 1) Have a property that can hold where the hyperlink is pointing to. (e.g. like the NavigateUrl property...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.