how to use the value of textBox placed on one page on to another page
-
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
-
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
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
-
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
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 )
-
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 )
-
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 )"
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 )
-
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
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
-
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 )"
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 usingRequest.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
-
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 )"
-
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
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
-
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
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 -
-
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
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