How to pass '&' in the querystring with value
-
I have function where I get name of the manufacturer in datatable.These manufacturer name comes as link in my usercontrol list.When I click it, it get passed in querystring for search result. Example: http://xyz.com/productlist.aspx?Section=Terminals&Manufacturer=Lenovo pc but in list I have Lenovo pc & NetStation My request is passes as
<% If Manufacturer = "" Then%>
<h2 class="subheading">
Manufacturers</h2>
<ul>
<% While Manufacturers.Read()
'Response.Write("<li><a href='/ProductList/" & Section & "/" & Manufacturers(0) & "/" & MinPrice & "/" & MaxPrice & "/" & Search & "'>" & Manufacturers(0) & "</a>(" & Manufacturers(1) & ")</li>")
Response.Write("<li><a href='/productlist.aspx?Section=" & Section & "&Manufacturer=" & Manufacturers(0) & "&MinPrice=" & MinPrice & "&MaxPrice=" & MaxPrice & "&Search=" & Search & "'>" & Manufacturers(0) & "</a>(" & Manufacturers(1) & ")</li>")
End While%>
</ul>
<% Else%>
<h2 class="subheading">
Manufacturers</h2>
<ul>
<%--<% Response.Write("<li><a href='/ProductList/" & Section & "/NULL/" & MinPrice & "/" & MaxPrice & "/" & Search & "'>" & Manufacturer & "- Remove Selection</a></li>")
%>--%>
<% Response.Write("<li><a href='/productlist.aspx?Section=" & Section & "&MinPrice=" & MinPrice & "&MaxPrice=" & MaxPrice & "&Search=" & Search & "'>" & Manufacturer & "- Remove Selection</a></li>")
%></ul> <%End If%>
in above url I want http://xyz.com/productlist.aspx?Section=Terminals&Manufacturer=Lenovo pc & NetStaions
-
I have function where I get name of the manufacturer in datatable.These manufacturer name comes as link in my usercontrol list.When I click it, it get passed in querystring for search result. Example: http://xyz.com/productlist.aspx?Section=Terminals&Manufacturer=Lenovo pc but in list I have Lenovo pc & NetStation My request is passes as
<% If Manufacturer = "" Then%>
<h2 class="subheading">
Manufacturers</h2>
<ul>
<% While Manufacturers.Read()
'Response.Write("<li><a href='/ProductList/" & Section & "/" & Manufacturers(0) & "/" & MinPrice & "/" & MaxPrice & "/" & Search & "'>" & Manufacturers(0) & "</a>(" & Manufacturers(1) & ")</li>")
Response.Write("<li><a href='/productlist.aspx?Section=" & Section & "&Manufacturer=" & Manufacturers(0) & "&MinPrice=" & MinPrice & "&MaxPrice=" & MaxPrice & "&Search=" & Search & "'>" & Manufacturers(0) & "</a>(" & Manufacturers(1) & ")</li>")
End While%>
</ul>
<% Else%>
<h2 class="subheading">
Manufacturers</h2>
<ul>
<%--<% Response.Write("<li><a href='/ProductList/" & Section & "/NULL/" & MinPrice & "/" & MaxPrice & "/" & Search & "'>" & Manufacturer & "- Remove Selection</a></li>")
%>--%>
<% Response.Write("<li><a href='/productlist.aspx?Section=" & Section & "&MinPrice=" & MinPrice & "&MaxPrice=" & MaxPrice & "&Search=" & Search & "'>" & Manufacturer & "- Remove Selection</a></li>")
%></ul> <%End If%>
in above url I want http://xyz.com/productlist.aspx?Section=Terminals&Manufacturer=Lenovo pc & NetStaions
For passing any special character through QueryString, It is safe to use HttpUtility.UrlEncode() Following example will serve your purpose:
string query = "City=" + HttpUtility.UrlEncode(txtCity.Text);
query += "&Hotel=" + HttpUtility.UrlEncode(txtHotel.Text);Response.Redirect("page1.aspx?" + query)
Hope this will help.
Anurag Gandhi. http://www.gandhisoft.com Life is a computer program and every one is the programmer of his own life.
-
I have function where I get name of the manufacturer in datatable.These manufacturer name comes as link in my usercontrol list.When I click it, it get passed in querystring for search result. Example: http://xyz.com/productlist.aspx?Section=Terminals&Manufacturer=Lenovo pc but in list I have Lenovo pc & NetStation My request is passes as
<% If Manufacturer = "" Then%>
<h2 class="subheading">
Manufacturers</h2>
<ul>
<% While Manufacturers.Read()
'Response.Write("<li><a href='/ProductList/" & Section & "/" & Manufacturers(0) & "/" & MinPrice & "/" & MaxPrice & "/" & Search & "'>" & Manufacturers(0) & "</a>(" & Manufacturers(1) & ")</li>")
Response.Write("<li><a href='/productlist.aspx?Section=" & Section & "&Manufacturer=" & Manufacturers(0) & "&MinPrice=" & MinPrice & "&MaxPrice=" & MaxPrice & "&Search=" & Search & "'>" & Manufacturers(0) & "</a>(" & Manufacturers(1) & ")</li>")
End While%>
</ul>
<% Else%>
<h2 class="subheading">
Manufacturers</h2>
<ul>
<%--<% Response.Write("<li><a href='/ProductList/" & Section & "/NULL/" & MinPrice & "/" & MaxPrice & "/" & Search & "'>" & Manufacturer & "- Remove Selection</a></li>")
%>--%>
<% Response.Write("<li><a href='/productlist.aspx?Section=" & Section & "&MinPrice=" & MinPrice & "&MaxPrice=" & MaxPrice & "&Search=" & Search & "'>" & Manufacturer & "- Remove Selection</a></li>")
%></ul> <%End If%>
in above url I want http://xyz.com/productlist.aspx?Section=Terminals&Manufacturer=Lenovo pc & NetStaions
You can encode the url before sending using
urlencode
and do the reverse while receiving.Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
-
For passing any special character through QueryString, It is safe to use HttpUtility.UrlEncode() Following example will serve your purpose:
string query = "City=" + HttpUtility.UrlEncode(txtCity.Text);
query += "&Hotel=" + HttpUtility.UrlEncode(txtHotel.Text);Response.Redirect("page1.aspx?" + query)
Hope this will help.
Anurag Gandhi. http://www.gandhisoft.com Life is a computer program and every one is the programmer of his own life.
Sorry ! I haven't seen your post before reply .
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
-
Sorry ! I haven't seen your post before reply .
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
:)
Anurag Gandhi. http://www.gandhisoft.com Life is a computer program and every one is the programmer of his own life.