开发者

Characters get trimmed when sending values from one page to another in asp.net

开发者 https://www.devze.com 2023-04-06 09:57 出处:网络
I am sending some values from one page to another in asp.net using javascript. I have declared JS in parent page and the values are being sent to child page and fetched in code behind page using Reque

I am sending some values from one page to another in asp.net using javascript. I have declared JS in parent page and the values are being sent to child page and fetched in code behind page using Request.Querystring. Look to my previous question here

To give you a detailed look, See below example

chStatusReport.Attributes.Add("onclick", "javascript:return Navigate( '" + varTrimmed+ "' );");

JS to open a child page is under

<script type="text/javascript" language="javascript">
        function Navigate(status) {
        window.open("ChildPage.aspx?status=" + status)
        return false;
        }
    </script>开发者_如何学Python;

Code fetching the value pass from parent to child page.

 if (Request.QueryString.Count!=0)

 { svar1= Request.QueryString["status"];
   }

Values that are being passed are like 1 )Tom & Peter 2 ) Laurence & Hardy

The values that i get are 1 ) Tom 2) Laurence

Why the remaining text get trimmed?


Are you actually passing Tom & Peter? I.e., ChildPage.aspx?status=Tom & Peter?

If you are, then the query string will have:

QueryString["Status"] with Tom and QueryString["Peter"].

The & is a delmiter between value pairs in the query string.

You'll need to URL Encode the URI. Take a look at JavaScript encodeURIComponent.


You can't use & directly in querystring.

You have to either encode or change & to another unicode manually and translate it back.

Here is a link for explanation.

http://www.kamath.com/codelibrary/cl006_url.asp

0

精彩评论

暂无评论...
验证码 换一张
取 消