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. Trim command ?

Trim command ?

Scheduled Pinned Locked Moved ASP.NET
databasehelptutorialquestion
16 Posts 5 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.
  • K Offline
    K Offline
    Krishna Varadharajan
    wrote on last edited by
    #1

    How to use trim command in query string. query string is working but it was redirecting only the first word. if we give like hp & co. than it redirecting only hp, so the record was not found in the redirecting page. can u pls help me.

    krishna

    N G 2 Replies Last reply
    0
    • K Krishna Varadharajan

      How to use trim command in query string. query string is working but it was redirecting only the first word. if we give like hp & co. than it redirecting only hp, so the record was not found in the redirecting page. can u pls help me.

      krishna

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      krishnavaradharajan wrote:

      hp & co.

      You have to escape & symbol. Use Server.URlEncode() before passing such values. Do Server.URLDecode() when getting it.

      All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

      K G 2 Replies Last reply
      0
      • N N a v a n e e t h

        krishnavaradharajan wrote:

        hp & co.

        You have to escape & symbol. Use Server.URlEncode() before passing such values. Do Server.URLDecode() when getting it.

        All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

        K Offline
        K Offline
        Krishna Varadharajan
        wrote on last edited by
        #3

        If i use like that them error was showing like... No overload for method 'UrlEncode' takes '0' arguments

        krishna

        K 1 Reply Last reply
        0
        • K Krishna Varadharajan

          If i use like that them error was showing like... No overload for method 'UrlEncode' takes '0' arguments

          krishna

          K Offline
          K Offline
          Krishna Varadharajan
          wrote on last edited by
          #4

          I have given like redirecting from.. Server.UrlEncode(); view = Request.QueryString.Get("view"); redircting to.. Server.UrlDecode(); pid = Request.QueryString.Get("pid");

          krishna

          N 1 Reply Last reply
          0
          • K Krishna Varadharajan

            I have given like redirecting from.. Server.UrlEncode(); view = Request.QueryString.Get("view"); redircting to.. Server.UrlDecode(); pid = Request.QueryString.Get("pid");

            krishna

            N Offline
            N Offline
            N a v a n e e t h
            wrote on last edited by
            #5

            string SomeVariable = Server.UrlEncode(YourValueTobeEncoded);

            Append this variable with the URL you are redirecting to. When getting value do

            string View = Server.UrlDecode(Request.QueryString.Get(YourQryStringVar))

            All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

            K 3 Replies Last reply
            0
            • N N a v a n e e t h

              string SomeVariable = Server.UrlEncode(YourValueTobeEncoded);

              Append this variable with the URL you are redirecting to. When getting value do

              string View = Server.UrlDecode(Request.QueryString.Get(YourQryStringVar))

              All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

              K Offline
              K Offline
              Krishna Varadharajan
              wrote on last edited by
              #6

              we are encripting the data...directly redircting...without using encoding and decoding..

              krishna

              Y 1 Reply Last reply
              0
              • N N a v a n e e t h

                string SomeVariable = Server.UrlEncode(YourValueTobeEncoded);

                Append this variable with the URL you are redirecting to. When getting value do

                string View = Server.UrlDecode(Request.QueryString.Get(YourQryStringVar))

                All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

                K Offline
                K Offline
                Krishna Varadharajan
                wrote on last edited by
                #7

                Its no working, we are not using this encoding and decoding, with using this will u give me the solution

                krishna

                1 Reply Last reply
                0
                • N N a v a n e e t h

                  string SomeVariable = Server.UrlEncode(YourValueTobeEncoded);

                  Append this variable with the URL you are redirecting to. When getting value do

                  string View = Server.UrlDecode(Request.QueryString.Get(YourQryStringVar))

                  All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

                  K Offline
                  K Offline
                  Krishna Varadharajan
                  wrote on last edited by
                  #8

                  without using encoding and decoding...

                  krishna

                  M 1 Reply Last reply
                  0
                  • K Krishna Varadharajan

                    without using encoding and decoding...

                    krishna

                    M Offline
                    M Offline
                    Malcolm Smart
                    wrote on last edited by
                    #9

                    Give us a clue - post the code you are using to generate the URL.

                    "More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF

                    "This time yesterday, I still had 24 hours to meet the deadline I've just missed today."

                    K 1 Reply Last reply
                    0
                    • M Malcolm Smart

                      Give us a clue - post the code you are using to generate the URL.

                      "More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF

                      "This time yesterday, I still had 24 hours to meet the deadline I've just missed today."

                      K Offline
                      K Offline
                      Krishna Varadharajan
                      wrote on last edited by
                      #10

                      Redirecting from.. public partial class search : System.Web.UI.Page { int pageSize = 5; string view = ""; SqlConnection con = new SqlConnection("server=5.53.4;Database=ecn;User ID=aaa;pwd=bbb"); protected void Page_Load(object sender, EventArgs e) { view = Request.QueryString.Get("view"); if (view == null) { view = ""; } //String abc; //abc = Request.QueryString["ID"]; } ===== Redircting to.. public partial class product1 : System.Web.UI.Page { string pid = ""; SqlConnection con = new SqlConnection("server= 5.53.4;Database=ecn;User ID=aaa;pwd=bbb"); protected void Page_Load(object sender, EventArgs e) { //string pid = Server.UrlDecode(Request.QueryString.Get("view")); pid = Request.QueryString.Get("pid"); } protected void getDetails() { con.Open(); SqlCommand cmd = new SqlCommand("select * from onlinegoa1 where companyname ='"+pid+"'",con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds= new DataSet(); da.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); con.Close(); } } krishna

                      krishna

                      M 1 Reply Last reply
                      0
                      • K Krishna Varadharajan

                        Redirecting from.. public partial class search : System.Web.UI.Page { int pageSize = 5; string view = ""; SqlConnection con = new SqlConnection("server=5.53.4;Database=ecn;User ID=aaa;pwd=bbb"); protected void Page_Load(object sender, EventArgs e) { view = Request.QueryString.Get("view"); if (view == null) { view = ""; } //String abc; //abc = Request.QueryString["ID"]; } ===== Redircting to.. public partial class product1 : System.Web.UI.Page { string pid = ""; SqlConnection con = new SqlConnection("server= 5.53.4;Database=ecn;User ID=aaa;pwd=bbb"); protected void Page_Load(object sender, EventArgs e) { //string pid = Server.UrlDecode(Request.QueryString.Get("view")); pid = Request.QueryString.Get("pid"); } protected void getDetails() { con.Open(); SqlCommand cmd = new SqlCommand("select * from onlinegoa1 where companyname ='"+pid+"'",con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds= new DataSet(); da.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); con.Close(); } } krishna

                        krishna

                        M Offline
                        M Offline
                        Malcolm Smart
                        wrote on last edited by
                        #11

                        We need to see the code that generates the URL which contains the '&' which is causing you problems. You have just given code that reads from the Request collection.

                        "More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF

                        "This time yesterday, I still had 24 hours to meet the deadline I've just missed today."

                        1 Reply Last reply
                        0
                        • K Krishna Varadharajan

                          we are encripting the data...directly redircting...without using encoding and decoding..

                          krishna

                          Y Offline
                          Y Offline
                          YeHtut
                          wrote on last edited by
                          #12

                          Actually Server.UrlEncode() and Server.URLDecode() is better. If u don't want to user like this. u try to replace your character "&" to %26 :) Ye Htut

                          1 Reply Last reply
                          0
                          • N N a v a n e e t h

                            krishnavaradharajan wrote:

                            hp & co.

                            You have to escape & symbol. Use Server.URlEncode() before passing such values. Do Server.URLDecode() when getting it.

                            All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

                            G Offline
                            G Offline
                            Guffa
                            wrote on last edited by
                            #13

                            N a v a n e e t h wrote:

                            Do Server.URLDecode() when getting it.

                            That's done automatically when you are reading values from the Request.QueryString collection, so you should not do that another time in your code.

                            --- "Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things." -- Douglas Adams

                            N K 2 Replies Last reply
                            0
                            • K Krishna Varadharajan

                              How to use trim command in query string. query string is working but it was redirecting only the first word. if we give like hp & co. than it redirecting only hp, so the record was not found in the redirecting page. can u pls help me.

                              krishna

                              G Offline
                              G Offline
                              Guffa
                              wrote on last edited by
                              #14

                              krishnavaradharajan wrote:

                              query string is working

                              No, it's not working. The values that you put in the url is not encoded properly, so the url is invalid. When putting values in a query string, you have to encode them using Server.UrlEncode so that characters that have a special meaning in an url (or are invalid in an url, like spaces) are replaced with the proper encoded values. Example: string name = "hp & co"; string home = "http://www.hpco.acme"; string url = "SomePage.aspx?cmpName=" + Server.UrlEncode(name) + "&cmpUrl=" + Server.UrlEncode(home); The contents of the url variable will be: "SomePage.aspx?cmpName=hp+%26+co&cmpUrl=http%3a%2f%2fwww.hpco.acme"

                              --- "Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things." -- Douglas Adams

                              1 Reply Last reply
                              0
                              • G Guffa

                                N a v a n e e t h wrote:

                                Do Server.URLDecode() when getting it.

                                That's done automatically when you are reading values from the Request.QueryString collection, so you should not do that another time in your code.

                                --- "Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things." -- Douglas Adams

                                N Offline
                                N Offline
                                N a v a n e e t h
                                wrote on last edited by
                                #15

                                Thanks Guffa. I didn't noticed that

                                All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

                                1 Reply Last reply
                                0
                                • G Guffa

                                  N a v a n e e t h wrote:

                                  Do Server.URLDecode() when getting it.

                                  That's done automatically when you are reading values from the Request.QueryString collection, so you should not do that another time in your code.

                                  --- "Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things." -- Douglas Adams

                                  K Offline
                                  K Offline
                                  Krishna Varadharajan
                                  wrote on last edited by
                                  #16

                                  Thanx its working....

                                  krishna

                                  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