传递名称包含&使用查询字符串到下一页 [英] Pass name containing & to next page using query string

查看:106
本文介绍了传递名称包含&使用查询字符串到下一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在第一页的传递代码

  protected   void  btnsbt_Click( object  sender,EventArgs e)
{
DateTime a = DateTime.ParseExact(txtfrmdate.Text,< span class =code-string> 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 + );
}



当我将名称A& A CONTAINER CONVERSIONS传递到下一页时,我只得到A。



第二页的代码:

 custname1 = Request.QueryString [   CustName]; 

解决方案

对查询进行编码使用UrlEncode的字符串: https:// msdn。 microsoft.com/en-us/library/system.web.httputility.urlencode%28v=vs.110%29.aspx [ ^ ]


 custname1 = Request.QueryString [CustName]; 

是正确的。


除了Kornfeld Eliyahu之外,这也是一个解决方案。 Peter117解决方案。



http://www.aspsn ippets.com/Articles/Encrypt-and-Decrypt-QueryString-Parameter-Values-in-ASPNet-using-C-and-VBNet.aspx

This is my passing code in first page

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:

custname1 = Request.QueryString["CustName"];

解决方案

Encode the query string using UrlEncode: https://msdn.microsoft.com/en-us/library/system.web.httputility.urlencode%28v=vs.110%29.aspx[^]


custname1 = Request.QueryString["CustName"];

is correct .


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


这篇关于传递名称包含&amp;使用查询字符串到下一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆