Hi, I'm very much a newbie with ASP.Net from th UK and have not much ASP knowledge but I'm an experienced VB developer trying to learn! Firstly, what's the best way to pass information between two webforms? I have a logon screen that returns access rights from
a database, how do I pass this string to the next webform? Secondly, I understand that I just call a Response.Redirect to go to the next webform. Do I have to do anything to unload the logon webform or does ASP.Net "take care of it" for me? Thirdly, If I use
frames, how do I pass information between each frame if each frame contains a seperate ASPX page? I hope this makes sense. Regards, Andy C
1) You could pass your string in the querystring if it is not too long, you could store it in a session variable, you could not pass it at all and then look it up on the next page based on the user name, etc. There's a ton of ways to do this. 2) ASP.NET "takes
care of it" 3) One way is to use JavaScript.
You can pass using the query string. You can always do something like this:
'String Variable to redirect to another form
Dim strRedirect as String
'Format the string with appropriate parameters
strRedirect = String.Format("yourpage.aspx?userName0={0}¶meter1={1}&...parameterx={x}", dtrQuery("user_name"), etc...)
'
'
'
'Later in your code redirect to another page using strRedirect
Response.Redirect(strRedirect)
'
'
'
'In the new page load event, gather information from query string
'Page Load
sub Page_Load ( s as object, e as eventargs )
Dim strUserName as String = Request.QueryString("userName")
'Repeat for rest of parameters
'
'
end sub
'Do what needs to get done with passed information
This method is called using placeholders. The sources for your parameters could be a datareader, form controls, what have you. The sources must be listed in the order that they
appear in the query string, like displayed above. Good luck, hope this helps. Signed, Jesse Williams
Andy C
Member
497 Points
108 Posts
Passing info between two webforms and others.
Aug 22, 2003 02:27 PM|LINK
russnem
Contributor
7001 Points
1389 Posts
ASPInsiders
MVP
Re: Passing info between two webforms and others.
Aug 22, 2003 02:43 PM|LINK
phishpan
Member
40 Points
8 Posts
Re: Passing info between two webforms and others.
Aug 22, 2003 03:03 PM|LINK
'String Variable to redirect to another form Dim strRedirect as String 'Format the string with appropriate parameters strRedirect = String.Format("yourpage.aspx?userName0={0}¶meter1={1}&...parameterx={x}", dtrQuery("user_name"), etc...) ' ' ' 'Later in your code redirect to another page using strRedirect Response.Redirect(strRedirect) ' ' ' 'In the new page load event, gather information from query string 'Page Load sub Page_Load ( s as object, e as eventargs ) Dim strUserName as String = Request.QueryString("userName") 'Repeat for rest of parameters ' ' end sub 'Do what needs to get done with passed informationThis method is called using placeholders. The sources for your parameters could be a datareader, form controls, what have you. The sources must be listed in the order that they appear in the query string, like displayed above. Good luck, hope this helps. Signed, Jesse Williams