Session State Help

Reply Forum
Forum postLisa @ 2011-09-16 15:45:42
ReplyReply to
Could someone please help me of where I am going wrong with this code?

{

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class frmPersonnelVerified : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//1. declare Variables
errorMessage ="";
bool OK = true;
//2.If statements for input validations & coloring text box
//This is an example


if (Request["txtFirstName"].ToString().Trim() == "")

{

txtFirstName.BackColor = System.Drawing.Color.Yellow;

errorMessage = errorMessage + "First Name may not be empty.";
OK = false;



}

else


{

txtFirstName.BackColor = System.Drawing.Color.White;

}

if (OK)


//3. Date validations
//Add date validations here

//4. Then the Session codes to transfer data all the way to the end of submit button codes.
//example

if (OK)


{
Session["txtFirstName"] = txtFirstName.Text;
Session["txtLastName"] = txtLastName.Text;
Session["txtPayRate"] = txtPayRate.Text;
Session["txtStartDate"] = txtStartDate.Text;
Session["txtEndDate"] = txtEndDate.Text;
Response.Redirect("frmPersonnelVerified.aspx");
}
else
lblError.Text = errorMessage;

}

In frmPersonnelVerified.aspx.cs


We need to modify the code we added last week to look like below.

protected void Page_Load(object sender, EventArgs e)
{
//Your comments here
txtVerifiedInfo.Text = Session["txtFirstName"].ToString() +
"\n" + Session["txtLastName"].ToString() +
"\n" + Session["txtPayRate"].ToString() +
"\n" + Session["txtStartDate"].ToString() +
"\n" + Session["txtEndDate"].ToString();

}





}
}











© net-tutorials.com 2006 - 2012

MailContact net-tutorials.com