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 use the value of textBox placed on one page on to another page

how to use the value of textBox placed on one page on to another page

Scheduled Pinned Locked Moved ASP.NET
csharptutorialasp-netdatabasehelp
11 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.
  • M Offline
    M Offline
    mavii
    wrote on last edited by
    #1

    i am designing an application in ASP.Net using C# in Visual studio2005. while making crystal reports, my requirement is that when user enter any value(e.g, year) in the textBox and click the button the values according to user requiredment are displayed in report. but to load report i am writing code in "crystalReportViewer1_Load" and in query i want to use the value of textBox which is present on previous page. i have write the code as: public static string s1 = textBox1.Text; public static string s2 = textBox1.Text; and in "crystalReportViewer1_Load" i hav write string s3 = rescue15.reports.s1; string s4 = rescue15.reports.s2; but the following error comes Error 7 An object reference is required for the nonstatic field, method, or property 'rescue15.reports.textBox1' can anyone guide me plz

    R C 2 Replies Last reply
    0
    • M mavii

      i am designing an application in ASP.Net using C# in Visual studio2005. while making crystal reports, my requirement is that when user enter any value(e.g, year) in the textBox and click the button the values according to user requiredment are displayed in report. but to load report i am writing code in "crystalReportViewer1_Load" and in query i want to use the value of textBox which is present on previous page. i have write the code as: public static string s1 = textBox1.Text; public static string s2 = textBox1.Text; and in "crystalReportViewer1_Load" i hav write string s3 = rescue15.reports.s1; string s4 = rescue15.reports.s2; but the following error comes Error 7 An object reference is required for the nonstatic field, method, or property 'rescue15.reports.textBox1' can anyone guide me plz

      R Offline
      R Offline
      Riza Azmi
      wrote on last edited by
      #2

      Hi mavii what if like this? session("s1") = textBox1.Text; session("s2") = textBox1.Text; and in "crystalReportViewer1_Load" string s3 = session("s1"); string s4 = session("s2"); Is it solving the problem? (I am a new with CR also).

      Regards, Riza Azmi Simple thing should be simple, complex thing should be possible

      M 1 Reply Last reply
      0
      • M mavii

        i am designing an application in ASP.Net using C# in Visual studio2005. while making crystal reports, my requirement is that when user enter any value(e.g, year) in the textBox and click the button the values according to user requiredment are displayed in report. but to load report i am writing code in "crystalReportViewer1_Load" and in query i want to use the value of textBox which is present on previous page. i have write the code as: public static string s1 = textBox1.Text; public static string s2 = textBox1.Text; and in "crystalReportViewer1_Load" i hav write string s3 = rescue15.reports.s1; string s4 = rescue15.reports.s2; but the following error comes Error 7 An object reference is required for the nonstatic field, method, or property 'rescue15.reports.textBox1' can anyone guide me plz

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        You can't, because the other page just doesn't exist anymore. You can do one of several things - 1 - store the value in the session ( as someone showed you ) 2 - put the value on the URL when you navigate to the second page ( the advantage of this is that your new page becomes bookmarkable )

        Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        M 1 Reply Last reply
        0
        • C Christian Graus

          You can't, because the other page just doesn't exist anymore. You can do one of several things - 1 - store the value in the session ( as someone showed you ) 2 - put the value on the URL when you navigate to the second page ( the advantage of this is that your new page becomes bookmarkable )

          Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          M Offline
          M Offline
          mavii
          wrote on last edited by
          #4

          can u plz explain your following sugesstion, i am not exactly getting what to do " put the value on the URL when you navigate to the second page ( the advantage of this is that your new page becomes bookmarkable )"

          C N R 3 Replies Last reply
          0
          • M mavii

            can u plz explain your following sugesstion, i am not exactly getting what to do " put the value on the URL when you navigate to the second page ( the advantage of this is that your new page becomes bookmarkable )"

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            If you had a list of songs, for example, and you were going to a page that printed the lyrics, then if each song had an Id, each song title could be rendered as a link, but the links could be lyrics.aspx?songId=1 lyrics.aspx?songId=2 lyrics.aspx?songId=3 and so on. Then lyrics.aspx could read the songId from the query string and use it in a SQL query to retrieve the correct lyrics and render them.

            Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

            1 Reply Last reply
            0
            • R Riza Azmi

              Hi mavii what if like this? session("s1") = textBox1.Text; session("s2") = textBox1.Text; and in "crystalReportViewer1_Load" string s3 = session("s1"); string s4 = session("s2"); Is it solving the problem? (I am a new with CR also).

              Regards, Riza Azmi Simple thing should be simple, complex thing should be possible

              M Offline
              M Offline
              mavii
              wrote on last edited by
              #6

              can u plz explain about how u have used session, i mean if i simply write like this, session("s1") = textBox1.Text; session("s2") = textBox1.Text; the following errors come: Error 1: Class, struct, or interface method must have a return type Error 2 Type expected Error 3 Invalid token ';' in class, struct, or interface member declaration

              1 Reply Last reply
              0
              • M mavii

                can u plz explain your following sugesstion, i am not exactly getting what to do " put the value on the URL when you navigate to the second page ( the advantage of this is that your new page becomes bookmarkable )"

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

                mavii wrote:

                put the value on the URL when you navigate to the second page ( the advantage of this is that your new page becomes bookmarkable

                He meant pass the values through URL as query string. So your URL will look like yourpage.aspx?TextBox1Value=somevalue&TextBox2Value=somevalue. This can be taken in the page using Request.QueryString["TextBox1Value"]. And these type of URL's are bookmarkable, ie if you add this to bookmarks, it can be reloaded after some time. But if you use session and bookmarked the page, you can't reload it because session will be timed out.

                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
                • M mavii

                  can u plz explain your following sugesstion, i am not exactly getting what to do " put the value on the URL when you navigate to the second page ( the advantage of this is that your new page becomes bookmarkable )"

                  R Offline
                  R Offline
                  Riza Azmi
                  wrote on last edited by
                  #8

                  Using query string is not safe regarding to security, whereas using session you can pass the value withouth user "see" it.

                  Regards, Riza Azmi Simple thing should be simple, complex thing should be possible

                  N J 2 Replies Last reply
                  0
                  • R Riza Azmi

                    Using query string is not safe regarding to security, whereas using session you can pass the value withouth user "see" it.

                    Regards, Riza Azmi Simple thing should be simple, complex thing should be possible

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

                    Riza Azmi wrote:

                    Using query string is not safe regarding to security,

                    Choosing the method is always depends on the requirement. If security is not a main concern, query strings are the best, and in that case usage of sessions are not advised. Moreover as Christian told, the page will be book markable. But if security is the main concern, still you can use query string but after encrypting the value. I always prefer query strings, since it won't keep anything in the server memory as session does.

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

                    R 1 Reply Last reply
                    0
                    • R Riza Azmi

                      Using query string is not safe regarding to security, whereas using session you can pass the value withouth user "see" it.

                      Regards, Riza Azmi Simple thing should be simple, complex thing should be possible

                      J Offline
                      J Offline
                      John ph
                      wrote on last edited by
                      #10

                      Tamper the Querystring Parameters. It's safe. Session Objects should be used only when you need a value through out the session accross the pages. When it's just a input parameter to generate a report which is not going to be the same every time you fetch the data then Query string is the best way here.

                      Regards
                       - J O H N -


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

                        Riza Azmi wrote:

                        Using query string is not safe regarding to security,

                        Choosing the method is always depends on the requirement. If security is not a main concern, query strings are the best, and in that case usage of sessions are not advised. Moreover as Christian told, the page will be book markable. But if security is the main concern, still you can use query string but after encrypting the value. I always prefer query strings, since it won't keep anything in the server memory as session does.

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

                        R Offline
                        R Offline
                        Riza Azmi
                        wrote on last edited by
                        #11

                        session is hide the data. that is what I called "secure". no matter encrypted or no, user still cannot deal with the value directly. session can store any datatype including datasource. thanks for sharing:)

                        Regards, Riza Azmi Simple thing should be simple, complex thing should be possible

                        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