Connecting Tech Pros Worldwide Forums | Help | Site Map

How to enforce "&"inside my queryString?

Mehdi
Guest
 
Posts: n/a
#1: Nov 19 '05
Hi,

I need to pass an URL via a hidden value as follow:

<input type="hidden" id="Test" runat="Server">

and on Page_Load I assign a value to this hidden input as follow:

Test.Value = "http://www.myserver.com?id=123&name=HomerSimpson";


However when I view the page source "&" is replaced with "&amp;" as the URL
changes to http://www.myserver.com?id=123&amp;name=HomerSimpson

How can I enforce the "&" inside my querystring when written into HTML?

I have tried to Server.UrlEncode, but the server that I am posting this
hidden value to, does not decode it before returning to the URL, and
unfortuntely I have no control over the way that they handle my hidden value
(URL with &amp;)

Thanks for your time.


Mehdi






MWells
Guest
 
Posts: n/a
#2: Nov 19 '05

re: How to enforce "&"inside my queryString?


You might be able to resolve this by writing out the entire value to an
<asp:Literal> control, e.g.

<asp:Literal id="TestLiteral" runat="Server">

TestLiteral.Text = String.Format (
@"<input type=""hidden"" value=""{0}"" id=""Test"" runat=""Server"">",
@"http://www.myserver.com?id=123&name=HomerSimpson"
);



"Mehdi" <nospam@nospam.nowhere> wrote in message
news:u7nHZVYBFHA.3708@TK2MSFTNGP14.phx.gbl...[color=blue]
> Hi,
>
> I need to pass an URL via a hidden value as follow:
>
> <input type="hidden" id="Test" runat="Server">
>
> and on Page_Load I assign a value to this hidden input as follow:
>
> Test.Value = "http://www.myserver.com?id=123&name=HomerSimpson";
>
>
> However when I view the page source "&" is replaced with "&amp;" as the[/color]
URL[color=blue]
> changes to http://www.myserver.com?id=123&amp;name=HomerSimpson
>
> How can I enforce the "&" inside my querystring when written into HTML?
>
> I have tried to Server.UrlEncode, but the server that I am posting this
> hidden value to, does not decode it before returning to the URL, and
> unfortuntely I have no control over the way that they handle my hidden[/color]
value[color=blue]
> (URL with &amp;)
>
> Thanks for your time.
>
>
> Mehdi
>
>
>
>
>[/color]


Mehdi
Guest
 
Posts: n/a
#3: Nov 19 '05

re: How to enforce "&"inside my queryString?


MWells,

You were right, it enforces the "&" inside my query string.

Thanks


Mehdi


Closed Thread