All, Thanks for the suggestions. I've included the entire script for my page below. This is a login page. I collect the user name and password. Then on postback I execute a db query to retrieve a dataset containing userFirstName, userName and Password. If the dataset isn't empty, I want to stuff the 'firstName' value from the dataset into a session variable so I can use it on later pages for personalization. A very simple concept that apparently isn't so simple to implement.
BTW: I'm using
VB and DreamWeaver for development.
<%@ Page Language="
VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicK eyToken=836f606ede05d46a,culture=neutral" %>
<MM:DataSet
id="dsauth_user"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_connUserInfo") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_connUserInfo") %>'
CommandText='<%# "SELECT firstName, userName, Password FROM dbo.UserProfile WHERE (userName = ?) and (Password = ?)" %>'
Expression='<%# IsPostBack %>'
Debug="true"
><Parameters>
<Parameter Name="@userName" Value='<%# IIf((Request.Form("txtuserName") <> Nothing), Request.Form("txtuserName"), "") %>' Type="VarChar" />
<Parameter Name="@Password" Value='<%# IIf((Request.Form("txtPassword") <> Nothing), Request.Form("txtPassword"), "") %>' Type="VarChar" />
</Parameters></MM:DataSet>
<MM:PageBind runat="server" PostBackBind="true" />
<script runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
dim MyName as string
If IsPostback then
If (dsauth_user.RecordCount <> 0) then
'CREATE A COOKIE - build later
'Create a session variable
'Session("userFirstName") = "MUDD" 'this code works!
MyName = Session("userFirstName") = dsauth_user.Tables(0).Rows(0).Item("firstName") 'this code doesn't
Session("userFirstName") = MyName
Response.redirect("Student_Page.aspx")
Else
Response.redirect("Login_Failed.aspx")
'Response.Write ("alert('The system did not recognize your user name and/or password.')")
End If
End If
End Sub
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>User Authentication DW script</title>
<link href="World.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>The FBC Online </h1>
<form method="POST" name="login" runat="server" >
<asp:ValidationSummary DisplayMode="BulletList" EnableClientScript="true" HeaderText="Error Summary" ID="vsErrors" runat="server" ShowMessageBox="true" ShowSummary="false" />
<p> Welcome to the FBC Online. We offer assistive and general on-line training courses<em>, </em>both self-paced and instructor-moderated, for Windows-based software products to help you master computer literacy.</p>
<p>Come learn with us! </p>
<p>Are you a registered FBC Online user? Use your user name and password to log in below.</p>
<label for="User Name"></label><p>
<strong>
<asp:Label ID="userName" Text="User Name:" AccessKey="U" runat="server" />
</strong> <asp:TextBox Columns="40" ID="txtuserName" runat="server" TextMode="SingleLine" /><asp:RequiredFieldValidator ControlToValidate="txtuserName" Display="None" EnableClientScript="true" ErrorMessage="User Name is required" ID="rfvuserName" runat="server" />
</p>
<p>
<strong>
<asp:Label ID="Password" Text="Password: " AccessKey="P" runat="server" /> </strong>
<asp:TextBox ID="txtPassword" Columns="40" runat="server" TextMode="Password" /><asp:RequiredFieldValidator ControlToValidate="txtPassword" Display="None" EnableClientScript="true" ErrorMessage="Password is required" ID="rfvPassword" runat="server" />
</p>
<p><asp:Button ID="btnLogin" runat="server" Text="Log In" CausesValidation="true" /></p>
<p>If you're new to FBC Online, <a href="Register.aspx" title="Register now! "><strong>Register now! </strong></a></p>
<input name="txtfirstName" type="hidden" value="<%# dsauth_user.FieldValue("firstName", Container) %>">
</form>
</body>
</html>