You can use session("variableName") Example Variable1 = session("Variable1") Or textbox1.text = session("Variable1") Also no need to dim a session variable Good Luck! Ali Abid Husain Senior Solutions Provider Total Programming Solutions, Inc. web: <http://www.tpsnow.com> http://www.tpsnow.com phone: 1 +623 935 5824 toll free: 888-TPSNOW1 "The Premier Choice.... for custom IT Solutions" -----Original Message----- From: higzog [mailto:[EMAIL PROTECTED] Sent: Monday, January 31, 2005 12:10 PM To: AspNetAnyQuestionIsOk@yahoogroups.com Subject: [AspNetAnyQuestionIsOk] Capturing session variable
Am a Newbee - I need to capture a session variable from the login script below to use for subsequent page queries. *************************** <%@ Page Language="VB" %> <script runat="server"> Sub LoginBtn_Click(Sender As Object, E As EventArgs) If Page.IsValid Then Dim userDS As New System.Data.DataSet userDS = LoginLookup(UserName.Text, UserPass.Text) If userDS.Tables(0).Rows.Count = 1 Then FormsAuthentication.RedirectFromLoginPage (UserName.Text, false) Else Msg.Text = "Invalid Credentials: Please try again" End If End If End Sub Function LoginLookup(ByVal username As String, ByVal password As String) As System.Data.DataSet Dim connectionString As String = "server='(local)'; trusted_connection=true; database='NLookup'" Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString) Dim queryString As String = "SELECT [SUPERVISOR].* FROM [SUPERVISOR] WHERE (([SUPERVISOR].[Username] = @Userna"& _ "me) AND ([SUPERVISOR].[Password] = @Password))" Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand dbCommand.CommandText = queryString dbCommand.Connection = dbConnection Dim dbParam_username As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter dbParam_username.ParameterName = "@Username" dbParam_username.Value = username dbParam_username.DbType = System.Data.DbType.String dbCommand.Parameters.Add(dbParam_username) Dim dbParam_password As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter dbParam_password.ParameterName = "@Password" dbParam_password.Value = password dbParam_password.DbType = System.Data.DbType.String dbCommand.Parameters.Add(dbParam_password) Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter dataAdapter.SelectCommand = dbCommand Dim dataSet As System.Data.DataSet = New System.Data.DataSet dataAdapter.Fill(dataSet) Return dataSet End Function </script> <html> <head> </head> <body style="FONT-FAMILY: arial"> <form runat="server"> <h2><img alt="Logo" src="logo.gif" /> </h2> <h2>Election Supervisor - Login Page </h2> <hr size="1" /> <table> <tbody> <tr> <td> Username:</td> <td> <asp:TextBox id="UserName" runat="server"></asp:TextBox> </td> <td> <asp:RequiredFieldValidator id="Requiredfieldvalidator1" runat="server" ErrorMessage="value required" Display="Static" ControlToValidate="UserName"></asp:RequiredFieldValidator> </td> </tr> <tr> <td> Password:</td> <td> <asp:TextBox id="UserPass" runat="server" TextMode="Password"></asp:TextBox> </td> <td> <asp:RequiredFieldValidator id="Requiredfieldvalidator2" runat="server" ErrorMessage="value required" Display="Static" ControlToValidate="UserPass"></asp:RequiredFieldValidator> </td> </tr> </tbody> </table> <asp:button id="LoginBtn" onclick="LoginBtn_Click" runat="server" text="Login"></asp:button> <p> <asp:Label id="Msg" runat="server" forecolor="red"></asp:Label> </p> </form> </body> </html> _____ Yahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED] cribe> * Your use of Yahoo! Groups is subject to the Yahoo! Terms of <http://docs.yahoo.com/info/terms/> Service. [Non-text portions of this message have been removed] Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/