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. the problem of using querystring

the problem of using querystring

Scheduled Pinned Locked Moved ASP.NET
csharpc++helptutorialquestion
8 Posts 2 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.
  • S Offline
    S Offline
    Seraph_summer
    wrote on last edited by
    #1

    I use the following format to redirect from a search input text, but I have the following poblem: when the input textbox (i.e. TextBox_Search.Text ) contains ++ or #, it results in wrong result: e.g if I input "C++", then search_text is not "C++" but only "C"; if I input "C#", then search_text is empty! this is maybe due to string problem, but I do not how to deal with these cases. protected void Button_Search_Click(object sender, EventArgs e) { Response.Redirect("~/BookList.aspx?search_text=" + TextBox_Search.Text + "&search_based=" + DropDownList_search_term.SelectedValue + "&display_content=booksearch"); } string search_text = Request.QueryString.Get("search_text");

    A 1 Reply Last reply
    0
    • S Seraph_summer

      I use the following format to redirect from a search input text, but I have the following poblem: when the input textbox (i.e. TextBox_Search.Text ) contains ++ or #, it results in wrong result: e.g if I input "C++", then search_text is not "C++" but only "C"; if I input "C#", then search_text is empty! this is maybe due to string problem, but I do not how to deal with these cases. protected void Button_Search_Click(object sender, EventArgs e) { Response.Redirect("~/BookList.aspx?search_text=" + TextBox_Search.Text + "&search_based=" + DropDownList_search_term.SelectedValue + "&display_content=booksearch"); } string search_text = Request.QueryString.Get("search_text");

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      why dont you use : Server.UrlEncode("C#") Thus

      Response.Redirect("~/BookList.aspx?search_text=" + Server.UrlEncode(TextBox_Search.Text) + "&search_based=" + Server.UrlEncode(DropDownList_search_term.SelectedValue) + "&display_content=booksearch");

      And also from client if you are using Javascript to send data use : javascript: encodeURIComponent("C#") I think this would cure your problem. Cheers. :cool:

      Abhishek Sur


      My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

      **Don't forget to click "Good Answer" if you like to.

      S 1 Reply Last reply
      0
      • A Abhishek Sur

        why dont you use : Server.UrlEncode("C#") Thus

        Response.Redirect("~/BookList.aspx?search_text=" + Server.UrlEncode(TextBox_Search.Text) + "&search_based=" + Server.UrlEncode(DropDownList_search_term.SelectedValue) + "&display_content=booksearch");

        And also from client if you are using Javascript to send data use : javascript: encodeURIComponent("C#") I think this would cure your problem. Cheers. :cool:

        Abhishek Sur


        My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

        **Don't forget to click "Good Answer" if you like to.

        S Offline
        S Offline
        Seraph_summer
        wrote on last edited by
        #3

        thanks, it seems that I need to learn a lot! there are many things I have not known!

        A 1 Reply Last reply
        0
        • S Seraph_summer

          thanks, it seems that I need to learn a lot! there are many things I have not known!

          A Offline
          A Offline
          Abhishek Sur
          wrote on last edited by
          #4

          :cool: More you work.. .more you learn.. a simple concept... :) :)

          Abhishek Sur


          My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

          **Don't forget to click "Good Answer" if you like to.

          S 1 Reply Last reply
          0
          • A Abhishek Sur

            :cool: More you work.. .more you learn.. a simple concept... :) :)

            Abhishek Sur


            My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

            **Don't forget to click "Good Answer" if you like to.

            S Offline
            S Offline
            Seraph_summer
            wrote on last edited by
            #5

            Hi, Abhishek, I have one more similar problem, which I do not know who to deal with: similary, I have one image field bind to the book cover, which is saved as the file path in a database, once again, I found that if the file contains C++ then the image file can not be correctly bound to the image field. do you have any idea why for this case? <asp:TemplateField HeaderText="Book Cover"> <ItemTemplate> <img style="height: 80px; width: 65px" src="<%# DataBinder.Eval(Container.DataItem, "BookCover") %>" alt="not available"/> </ItemTemplate> </asp:TemplateField>

            A 1 Reply Last reply
            0
            • S Seraph_summer

              Hi, Abhishek, I have one more similar problem, which I do not know who to deal with: similary, I have one image field bind to the book cover, which is saved as the file path in a database, once again, I found that if the file contains C++ then the image file can not be correctly bound to the image field. do you have any idea why for this case? <asp:TemplateField HeaderText="Book Cover"> <ItemTemplate> <img style="height: 80px; width: 65px" src="<%# DataBinder.Eval(Container.DataItem, "BookCover") %>" alt="not available"/> </ItemTemplate> </asp:TemplateField>

              A Offline
              A Offline
              Abhishek Sur
              wrote on last edited by
              #6

              Same as the earlier.. Does this work correctly ?

              ![](<%# Server.UrlEncode(DataBinder.Eval(Container.DataItem, )" alt="not available"/>

              :rose:

              Abhishek Sur


              My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

              **Don't forget to click "Good Answer" if you like to.

              S 1 Reply Last reply
              0
              • A Abhishek Sur

                Same as the earlier.. Does this work correctly ?

                ![](<%# Server.UrlEncode(DataBinder.Eval(Container.DataItem, )" alt="not available"/>

                :rose:

                Abhishek Sur


                My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

                **Don't forget to click "Good Answer" if you like to.

                S Offline
                S Offline
                Seraph_summer
                wrote on last edited by
                #7

                actually, I have tried this way, it does not work, but as you proposed again, then I tried again, and I find that the object should be conveted into string first, then it works! i.e.: <img style="height: 80px; width: 65px" src="<%# Server.UrlEncode(DataBinder.Eval(Container.DataItem, "BookCover").ToString()) %>" alt="not available"/> OK, great, I have got lot of help from you! You are quit active in this area, hopefully, more help can be obtained from you!

                A 1 Reply Last reply
                0
                • S Seraph_summer

                  actually, I have tried this way, it does not work, but as you proposed again, then I tried again, and I find that the object should be conveted into string first, then it works! i.e.: <img style="height: 80px; width: 65px" src="<%# Server.UrlEncode(DataBinder.Eval(Container.DataItem, "BookCover").ToString()) %>" alt="not available"/> OK, great, I have got lot of help from you! You are quit active in this area, hopefully, more help can be obtained from you!

                  A Offline
                  A Offline
                  Abhishek Sur
                  wrote on last edited by
                  #8

                  Yaah... Right... Server.UrlEncode expects the parameter as string .. :)

                  Abhishek Sur


                  My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

                  **Don't forget to click "Good Answer" if you like to.

                  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