468,784 Members | 1,612 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

How to enforce "&"inside my queryString?

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

Nov 19 '05 #1
2 1481
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" <no****@nospam.nowhere> wrote in message
news:u7**************@TK2MSFTNGP14.phx.gbl...
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


Nov 19 '05 #2
MWells,

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

Thanks
Mehdi
Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Arpan | last post: by
1 post views Thread by David Furey | last post: by
5 posts views Thread by chortler | last post: by
2 posts views Thread by beachboy | last post: by
1 post views Thread by EoRaptor013 | last post: by
3 posts views Thread by Tanmaya Kulkarni | last post: by
30 posts views Thread by Medvedev | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.