papa_k Posted September 16, 2003 Posted September 16, 2003 Is it possible to send data between aspx pages? eg. page one has variable student_id i need to send this to page two to display it. any ideas? Quote without time nothing ever ends
bungpeng Posted September 16, 2003 Posted September 16, 2003 There are several methods, but I recommend these 3 methods, depend on what is your situation: 1. use "querystring", value pass thought URL 2. use "cookies", value save in client machine, cookies enabled is require 3. use "session", need extra server memory and default timeout 20 minutes Quote
papa_k Posted September 16, 2003 Author Posted September 16, 2003 i am familiar with all of these. the server one is out of the question, as server variables are not allowed. the cookie one does depend on cookies being enabled as you said, so there is an element of trust that the user has got the cookies enabled. the last seems the best bet. BUT... how does this work exactly? you can send it two ways, one by putting data in the addess bar, and the other by passing it to the new page 'under cover'. where do i set this. am i correct in thinking that this is set in the form detail in the html with action = 'blah.aspx'? Quote without time nothing ever ends
bungpeng Posted September 16, 2003 Posted September 16, 2003 1. "Server one is out of the question, as server variables are not allowed"? Session allow you to keep your values in IIS server, it works similar to your "server variable" 2. to use Querystring, you can use "blah.aspx?var1=ABC&var2=DEF" Quote
papa_k Posted September 16, 2003 Author Posted September 16, 2003 1. "Server one is out of the question, as server variables are not allowed"? Session allow you to keep your values in IIS server, it works similar to your "server variable" 2. to use Querystring, you can use "blah.aspx?var1=ABC&var2=DEF" ok. session variables are forbidden on the web server that i connect to, they just dont allow them so i am not able to go down that route. i want to use 2. But i have a question / issue. When i have created the asp normal pages i have been able to send information between asp pages. since i am now using asp.net asp pages aka aspx extensions i can not get a button on the form that will submit the information on the page so that a new aspx page can pick it up. when i hit the submit button i keep gettin the original page appear. where do i tell the button / web page that it needs to open the next aspx page when the information is submitted? thanks for you help so far, keep it coming... papa_k Quote without time nothing ever ends
bungpeng Posted September 16, 2003 Posted September 16, 2003 How do you jump from first page to second page? If there is a [Next] button for example, then you can use Javascript to form your URL and use "top.location = ''" to second page Please remember to encode your variable's value before assign it to URL, in Javascript use "escape" and ASP.NET is "Server.URLEncode"... Quote
papa_k Posted September 16, 2003 Author Posted September 16, 2003 How do you jump from first page to second page? this is the problem. I dont know how to do this. when i have used bog standard asp before i have not had this problem. i set the html to look like this... <form method='post' action='nextpage.asp'> 'loads of form stuff </form> then i have my form submit button. when this is pressed it picks up what the action is set to at the top of the form and then opens that page. in the example above it would be nextpage.asp. then within the nextpage.asp i call request("whateverineed") when i want to display data from the previous page. i do not know how to do this in asp.net. i think that i have set up the above method in my aspx page but it does not work. when i click, what should be the HTML form SUBMIT command it does not call the next aspx page. i have set something up wrong. does anyone have an example they can post? what do you do to carry out the task i have described? Quote without time nothing ever ends
bungpeng Posted September 16, 2003 Posted September 16, 2003 I not quite understand your case, I will suggest you simplify your source and post it here, then we guide you straight.... If there is submit button in your first page to second page, then you will simply use a 'hidden textbox' to store your value, so when jump to second page, you can use Request.Form("textbox_name") to get your value Quote
papa_k Posted September 16, 2003 Author Posted September 16, 2003 a simple version of what i am after how do i set up the following in asp.net i want textbox1 on page1.aspx i want the user to enter information into page1.aspx and then press submit. this is the simple example of what i want to happen / the submit to do... if textbox1 is blank then stay on page1.aspx highlight textbox1 else open page2.aspx write what was typed into textbox1 onto page2.aspx endif now how do i carry this out. the problem i have at the moment is that i DO NOT HAVE A SUBMIT button that works. I can not create a submit button that will open the page2.aspx so that i can then write to the page2.aspx. all submit bottons that i have created so far just reload page1.aspx. Quote without time nothing ever ends
Administrators PlausiblyDamp Posted September 16, 2003 Administrators Posted September 16, 2003 in the buttons click event you can use response.redirect(url) or server.transfer(url) to go to another page Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
papa_k Posted September 16, 2003 Author Posted September 16, 2003 in the buttons click event you can use response.redirect(url) or server.transfer(url) to go to another page ok. how do i then access the value that was stored in the page1.aspx and write it to the screen? Quote without time nothing ever ends
Administrators PlausiblyDamp Posted September 16, 2003 Administrators Posted September 16, 2003 Response.Redirect("Newpagetogoto.aspx?text=" & text1.text) or similar will pass the value as part of the querystring Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
papa_k Posted September 16, 2003 Author Posted September 16, 2003 ok. that method sounds good. would it be possible to send the information via the ASP POST type method rather than the GET type method. Papa Quote without time nothing ever ends
papa_k Posted September 16, 2003 Author Posted September 16, 2003 ignore that last question. i have decided that by using frames i can achieve the 'hidden' data send. sorry if i appeared slow with the pick up. this is closed thanks for all your help. Papa ***** CLOSED ***** Quote without time nothing ever ends
Moderators Robby Posted September 16, 2003 Moderators Posted September 16, 2003 In this case it's preferable to use Server.Transfer() rather than Response.Redirect(). Quote Visit...Bassic Software
papa_k Posted September 16, 2003 Author Posted September 16, 2003 In this case it's preferable to use Server.Transfer() rather than Response.Redirect(). i assumes there is a technical difference as i have just coded the one suggested and it works fine, if not the same at the other one. Quote without time nothing ever ends
Moderators Robby Posted September 16, 2003 Moderators Posted September 16, 2003 Server.tranfer can only be used to open files on the same server as opposed to redirect wich can open any URL. Also, the former can maintain viewstate. Quote Visit...Bassic Software
LawS Posted December 19, 2003 Posted December 19, 2003 Your suggestion to use a Querystring will work for me but how do I read the var1 on the second page? Quote
Moderators Robby Posted December 19, 2003 Moderators Posted December 19, 2003 This thread is several months old, please start a new thread. Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.