Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to pass '&' in the querystring with value

How to pass '&' in the querystring with value

Scheduled Pinned Locked Moved ASP.NET
tutorialcomquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Niraj001
    wrote on last edited by
    #1

    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

    A A 2 Replies Last reply
    0
    • N Niraj001

      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

      A Offline
      A Offline
      Anurag Gandhi
      wrote on last edited by
      #2

      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.

      A 1 Reply Last reply
      0
      • N Niraj001

        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

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • A Anurag Gandhi

          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.

          A Offline
          A Offline
          Abhijit Jana
          wrote on last edited by
          #4

          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.

          A 1 Reply Last reply
          0
          • A Abhijit Jana

            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.

            A Offline
            A Offline
            Anurag Gandhi
            wrote on last edited by
            #5

            :)

            Anurag Gandhi. http://www.gandhisoft.com Life is a computer program and every one is the programmer of his own life.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups