Click here to Skip to main content
15,889,339 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my passing code in first page
C#
protected void btnsbt_Click(object sender, EventArgs e)
{
    DateTime a = DateTime.ParseExact(txtfrmdate.Text, "dd-MM-yyyy", null);
    DateTime b = DateTime.ParseExact(txttodate.Text, "dd-MM-yyyy", null);
    string c = txtCustomerName.Text.ToString();

    Response.Redirect("frmRptSalesBillWiseView.aspx?drop=" + a + "&radio=" + b + "&CustName=" + c + "");
}

When I pass the name "A & A CONTAINER CONVERSIONS" to the next page I'm getting only "A".

Code on the second page:
C#
custname1 = Request.QueryString["CustName"];
Posted
Updated 27-Apr-15 0:26am
v2

 
Share this answer
 
custname1 = Request.QueryString["CustName"];
is correct .
 
Share this answer
 
This can be a solution also in addition to "Kornfeld Eliyahu Peter117" solution.

http://www.aspsnippets.com/Articles/Encrypt-and-Decrypt-QueryString-Parameter-Values-in-ASPNet-using-C-and-VBNet.aspx
 
Share this answer
 
solved this problem using Server.UrlEncode()

Response.Redirect("frmRptSalesBillWiseView.aspx?drop=" + a + "&radio=" + b + "&CustName=" + Server.UrlEncode(c) + ""); }
 
Share this answer
 
Hi,

Please use like following code while redirecting.

Response.Redirect("frmRptSalesBillWiseView.aspx?drop=" + Server.HtmlEncode(a) + "&radio=" + Server.HtmlEncode(b) + "&CustName=" + Server.HtmlEncode(c) + "");

Use the following while retrieving the value form query string.


custname1 = Server.HtmlDecode(Convert.ToString(Request.QueryString["CustName"]));


Note: You can use HttpUtility.HtmlDecode / HttpUtility.HtmlEncode instead of Server.HtmlEncode / Server.HtmlDecode. it is depends on you choice.

Thank you,
 
Share this answer
 
Comments
Richard Deeming 27-Apr-15 10:23am    
Unsurprisingly, HtmlEncode is for encoding strings to display in an HTML context.

To encode strings to use in a URL, you need to use UrlEncode. The QueryString collection takes care of decoding the value for you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900