关于Request.QueryString
例如地址栏:
http://localhost:19304/BalloonShopTest/Catalog.aspx?DepartmentID=1&CategoryID=1
string departmentId = Request.QueryString["DepartmentID"];
string categoryId = Request.QueryString["CategoryID"];
为什么categoryId是空的,取不到值1
------解决方案--------------------aspx?DepartmentID=1&CategoryID=1 把&换成&试试
------解决方案--------------------一般 我们地址栏上的是这样儿的
http://localhost:19304/BalloonShopTest/Catalog.aspx?DepartmentID=1&CategoryID=1
------解决方案--------------------http://localhost:19304/BalloonShopTest/Catalog.aspx?DepartmentID=1&CategoryID=1
&换成&
string departmentId = Request.QueryString["DepartmentID"];
string categoryId = Request.QueryString["CategoryID"];
------解决方案--------------------aspx?DepartmentID=1&CategoryID=1
1楼正解
------解决方案--------------------C# code
HtmlEncode: 将 Html 源文件中不允许出现的字符进行编码,通常是编码以下字符"<"、">"、"&" 等。
HtmlDecode: 刚好跟 HtmlEncode 相关,解码出来原本的字符。
------解决方案--------------------
string str=String.Format("Catalog.aspx?DepartmentID={0}&CategoryID={1}", departmentID, categoryID);
str = str.Replace("&","&");