# Miscellaneous > Database Programming >  Tornado - Parameter Passing to other ASPX files

## paul mancuso

How are parameters, or exported data fields passed to other ASPX files?

Our tornado program is using a tabbed page with login.  On successful login, data from the password table is exported.  This exported data will be used in other ASPX files within the tabbed file.

An example would be nice...

Paul

----------


## Frank

A safe way to do that is to store the var in a session variable and then retrieve from the other aspx file. We must have covered this numerous times in examples. 

If the applications are in serial (same app) then use the export fields and columns to do that. Export fields and columns (raw also) is not trival and the above techique is not easy to apply an dyou have to use the export functions in Tornado.

FK

----------


## johnmooney

Frank,

We'd love to know where these examples are.  We've scoured the forum looking for something on session variables, but nothing really on how to use them.

We would like to avoid hard coding variables on URLs because our variables change depending on who logs in to the application.

We understand that you have to put the variable into a session variable, but we have yet to see how to pull the session variable from another ASPX file.

Also, how do we actually know if it is stuffing the variable into a session variable?  We can test it using the same aspx file, but that doesn't really solve the issue, because we need the variable to be GLOBAL in a sense.

Let me know if this made sense at all.

Thanks again
JM

----------


## Frank

Session Var are "Global" to the session. Master slave examples are everywhere. Selecetd items, exports, master/details...


FK

----------


## paul mancuso

Frank,

We are working on a very complex and involved application which requires Session variable passing to other .aspx files. Both John and I have worked on this issue all day and really need your help here.

Please direct us to the examples showing the use of Session variables with multi applications.

Also, have you found the solution for the login to muliple applications through a tabbed form?

thanks, Paul

----------


## Frank

How complicted SV passing can be ?
Ask John to explain the problem to me or you can try it here.

I thought I send yout the files for the tab aspx login

maintest.aspx
=============

<script language='vb' runat='server'>
Sub Page_Load(Source as Object, E as EventArgs)

   Dim X As New tornado.z()
   Dim GD as New Tornado.Getdata()
   Dim LstClick as string = GD.Get_LastClick

   X.dbQP = "U=1|S=1|PS=-1|TH=Ti= Main Test File"

   Dim login as string = ""
    login = "Type=db|DSN=Password.mdb|SQL=SELECT password,"
    login = login & "email FROM table1 WHERE ID = '[[ID]]'|"
    login = login & "LoginTitle=Login|FromAddr=support@aspdb.com|"
    login = login & "EmailSubject=Your Password|"
    login = login & "EmailBody=Your password/id is : [[LoginID]]/[[password]]"
  X.dbLogin = login 

   Dim mp1 as string = ""
      mp1 =  "type=3|style=17|"
      mp1 = mp1 & "FirstPage=http://localhost/tornado/scratch/test1.aspx|"
      mp1 = mp1 & "mw=600| mh=20| dw=900| dh=600| Ta=center"
   X.dbMenuParams = mp1

  Dim md1 as string = ""
      md1 =       "la=First Test File|"
      md1 = md1 & "u=http://localhost/tornado/scratch/test1.aspx,"
      md1 = md1 & "la=Second Test File|"
      md1 = md1 & "u=http://localhost/tornado/scratch/test2.aspx" 
  X.dbMenuData = md1

   Response.Write("<Center> &nbsp" & x.ASPdbMenu() & "</center><BR>")

End Sub
</script>

test1
=====
<script language='vb' runat='server'>
Sub Page_Load(Source as Object, E as EventArgs)

   Dim X As New tornado.z()
   Dim GD as New Tornado.Getdata()
   Dim LstClick as string = GD.Get_LastClick

   X.dbQP = "U=1|Q=Products|s=4|D=Nwind|PS=-1|TH=Ti= Test File 1"

   Dim login as string = ""
    login = "Type=db|DSN=Password.mdb|SQL=SELECT password,"
    login = login & "email FROM table1 WHERE ID = '[[ID]]'|"
    login = login & "LoginTitle=Login|FromAddr=support@aspdb.com|"
    login = login & "EmailSubject=Your Password|"
    login = login & "EmailBody=Your password/id is : [[LoginID]]/[[password]]"
   X.dbLogin = login 
   X.ASPdbNET()
End Sub
</script>


test2
=====
<script language='vb' runat='server'>
Sub Page_Load(Source as Object, E as EventArgs)

   Dim X As New tornado.z()
   Dim GD as New Tornado.Getdata()
   Dim LstClick as string = GD.Get_LastClick
   X.dbQP = "U=1|Q=employees|s=2|D=Nwind|NI=b5|PS=-1|TH=Ti= Test File 2"

   Dim login as string = ""
    login = "Type=db|D=Password.mdb|SQL=SELECT password,"
    login = login & "email FROM table1 WHERE ID = '[[ID]]'|"
    login = login & "LoginTitle=Login|FromAddr=support@aspdb.com|"
    login = login & "EmailSubject=Your Password|"
    login = login & "EmailBody=Your password/id is : [[LoginID]]/[[password]]"
  X.dbLogin = login 

   X.ASPdbNET()
End Sub
</script>

----------


## johnmooney

Ok, as you probably know by now, we have a main login, then after you are logged in, there is a main page with 2 tabbed .aspx files.

When each user logs on, we pull their department number according to their username (ex. John Smith is from Department 6)

So we would like to use this department number for each .aspx file.  We are trying to put the number into a session variable, then pull it back up when you click on either of the tabbed windows.

So, say John Smith from Department 6 successfully logs in, then when he clicks on the 1st tabbed window (or 2nd tabbed window), only the data pertaining to his department number should show up.

Hope this isn't too confusing...
JM

----------


## Frank

OK,, where is the problem? Note that you are talking a possible Application Variable. If that is the case then store that as Application variable. So ALL aspx files can use it.


FK

----------


## Frank

>>...Both John and I have worked on this issue all day and really need your help here.


I think this John is not John Crombe but instead, your programmer - right ???

A bit mix up becasue if our support cannot solve that, that'll be a challenge !!! For SV, it should be pretty simple.


FK

----------


## John

Hi Paul, John here...

It sounds like you just want to pass data from one page (a login page for example) to other pages (like the tabbed pages) that the user will click on, right?

To do this, you just store the data into a session variable and then retrieve it from your other pages.

Here it is in simple form...

Login page contains:
Session("MySavedVar") = "abc123"

Future page contains:
someval = Session("MySavedVar")

Now you will see the variable someval contains "abc123".  In fact, all pages the user accesses from then on can get that value out of Session("MySavedVar") whenever they wish.  You can even "re-write" that value by just using the same code as the Login Page shows above.

Session variables are in effect "Global" variables FOR EACH USER and DURING THEIR CURRENT SESSION.  This sounds like what you want because when John Smith logs in, you want to look up and remember once that he's in department 6 and then use that value from then on.  Just store that in a session variable i.e. Session("dept") = 6   (except that the value "6" here would be replaced by some value that you read from the database probably.

Hope this answers your question.  If not, please clarify.  Remember, we can also consult with you on an hourly basis to write some code snippets for you to get you going.

Take care,
John

----------


## paul mancuso

Frank and John,

Thanks for your input on all this.

Here's where we are now.  Saving Session Variables does work but only if you launch a second application while the browser is open.  And, that's normal behavior.  However, we are saving SV's then launching a second .aspx file using .ASPDBMenu and that's where the problem is.  It appears that the SV's are timing out because the call to .ASPdbMenu is closing the browser session thus wiping out the SV's.

We tested this theory using VB.NET and it works fine.  Please check this out as we can't continue without the ability to pass SV's..... 

AS for the Logout button.  Your solution is to code the .dbLogin on each .aspx file.  Isn't there a global solution which would work with .ASPdbMenu (eg tabbed page)?  Without a global solution, my users will need to login and out every time a tab is pressed.  That's not a solution.

Also, John Mooney is working with me in the development of this system. Don't be confused by that.

Finally, if need be, feel free to give me a call as I'll be glad to help iron this out with you....Paul

----------


## Frank

In that case, use the Application variable. It'll stay there.

FK

----------


## paul mancuso

Frank,

I just tried the application variable as you suggested,and the behavior is the same as the session variable.  It;s getting wiped out during the redirect to the second .aspx file.

Anyother suggestions?

----------


## paul mancuso

Frank,

I believe the .dbMenuData, which redirects the application to another page is problematic when using SV's.  In other words, SV's won't work with a tabbed page (.dbMenuParams).

Here's what I'm thinking.  If you issue a response.redirect (which is what I believe .dbMenudata is using, then you'll never get a SV to stay around.  This is because you need to use a full URL with the u=parameter in .dbMenuData. Which closes the session and opens a new browser.

I tested this theory using the server.transfer method of ASP.NET, which only requires a .aspx file name, no full URL.  And the SV's we're able to be called by the second .aspx file.

Paul

----------


## Frank

does not sound right. look at the following code - both session and application var works. Go from here and modify the code to illustrate the problem.

FK


maintest123.aspx
================
<script language='vb' runat='server'>
Sub Page_Load(Source as Object, E as EventArgs)
   Application("CommonVar") = "Frank"
   Session("CommonVar") = "Kwong"
   Dim X As New tornado.z()   
   Dim mp1 as string = ""
      mp1 =  "type=3|style=17|"
      mp1 = mp1 & "FirstPage=http://localhost/tornado/scratch/test111.aspx|"
      mp1 = mp1 & "mw=600| mh=20| dw=900| dh=600| Ta=center"
   X.dbMenuParams = mp1

  Dim md1 as string = ""
      md1 = "la=First Test File|"
      md1 = md1 & "u=http://localhost/tornado/scratch/test111.aspx,"
      md1 = md1 & "la=Second Test File|"
      md1 = md1 & "u=http://localhost/tornado/scratch/test222.aspx" 
  X.dbMenuData = md1
  Response.Write("<Center> &nbsp" & x.ASPdbMenu() & "</center><BR>")
End Sub
</script>


test111.aspx
============
<script language='vb' runat='server'>
Sub Page_Load(Source as Object, E as EventArgs)
   Dim X As New tornado.z()
   X.dbQP = "U=1|Q=Products|s=4|D=Nwind|gdf=0,1|TH=Ti= Test File 1"
   X.ASPdbNET()
   response.write("<P> Application Common Variable = " & Application("CommonVar"))
   response.write("<P> Session Common Variable = " & Session("CommonVar"))   
End Sub
</script>

test222.aspx
============
<script language='vb' runat='server'>
Sub Page_Load(Source as Object, E as EventArgs)
   Dim X As New tornado.z()
   X.dbQP = "U=2|Q=employees|s=2|D=Nwind|NI=b5|gdf=0,1|TH=  Ti= Test File 2"
   X.ASPdbNET()
   response.write("<P> Application Common Variable = " & Application("CommonVar"))
   response.write("<P> Session Common Variable = " & Session("CommonVar"))      
End Sub
</script>

----------


## paul mancuso

Frank/John

The answer to all this is "No, you can't use Session or Application Variables if you installed the IE Security Patch MS01-055.  Obviously, you did not install that patch.

Anyway, I found the answer on the MS Knowledge Base.  What you need to do is path the URL (from .dbMenuData and .dbMenuParams) using the IP address of the server, not it's server name. If you or anyone else is interested in the why's of the this, visit the MS Knowledge Base and read what it says...

It's taken us 3+ days to figure this out, which in development time is very expensive and painful. And, this question begs to be answered, "hasn't anyone else run into this problem?"

----------


## paul mancuso

Frank,

Your solution for the tab login is not a solution we can use.  The users will need to login then logout just to move to another tab. Is there a way to shut off the logout button.  Atleast if we had that option things would be straight forward, for the users.  

Also, is there a way to logout using ASP.NET such as formsauthentication.signout ?.  

Paul

----------


## Frank

I updated my server with auto updates and it is up to date. That means, all critical updates are loaded. SV and application Vars works fine. Look at this MS01-055 article ->

http://support.microsoft.com/default...b;en-us;316112

It says, if you install this patch then all the Session and Application variables will be gone, all asp, aspx and the whole framework will tank!!!

The reason for this patch seems to compensate the incorrect naming of the cookie/server names. 

That looks like an MS screw up to me as this patch they issued destroyed their entire Web Application framework (no SV and Cookies). Sometimes, When you created a bug, you have to call it a "feature" to get away with it. If everybody install this patch then, our phone or all web application developer's support line will ring off the hook. 

I do not have time to look in to the tab/login but I'll give you a patch tha you can hide the button and ssee how it works.


Frank

----------


## Frank

I tested the last maintest, test1, test2 files and I cannot duplicate the problem in having to logon/logoff to get to the other applications in the other tabs once logged in. Better check your SV as if you lost them then you are not login.

FK

----------


## johnmooney

Frank,

Nevermind, we found a workaround for our problem.  The login is now working, along with passing our session variables.  We had to point the URL's to our IP address so when it loaded the aspx files it could still find them in the same directory.  This was yet another workaround because there is a small problem with the tabbed menu feature.

The 'FirstPage' will allow you to just indicate the filename of the file you are pointing to (Firstpage=test.aspx)... but the Menudata for the actual tabbed menus will not let us do it when we use the same type of syntax.  This seemed a little strange, because we thought that these two things would share the same properties.

So we just used the whole url with our IP address in the beginning of it, and it seems to be working now.  We don't know what problems this will cause when we put this on the web, but we will soon find out (hopefully they won't be too major).

Our session variables were getting lost because the tabbed menu would open a new session for each tabbed page.  The URLs for each tab were the cause of this.

Thanks for your help on this-

JM

----------


## Frank

Add this line to all the test files at the top and check the session ID. They should be the same ->

   Response.write("<P>" & Session.SessionID & "<P>")

It is better to specify the full URL of the links to avoid unexpected "defaults" imposed by Tornado.

My goal is to make the feature as perfect as can be. So, describe the problem in more details when you have time and I'll look at it.


Frank

----------


## johnmooney

Yea we already used that to help us diagnose the issue before.  All is well with this problem now.  All session variables are functioning properly.

Thnx
JM

----------

