newbie - keeping my object data as page refreshes

A

AAJ

Hi all

I have some experience in 'Windows' programming but I am new to Web
programming, I wonder if anyone can help.

I have a middle layer object that brings some data from a database class .
The class reprsents a Callout, has lots of methods and properties and
manages the business logic..

I then have a html page (GUI layer) that creates an instance of a callout,
and from the callout object, it displays some textfields, labour etc plus
some datagrids based on some collections it holds.

Everything works fine until the page refreshes, at which time the object
seems to be destroyed and then recreated.

I want to keep the object alive with its existing data, on the server, and
connect back to it , ie. not create a new object each time. I know I could
use my Callouts WriteDate event to persist the data back to the SQLServer,
and then just re load it, but this isn't what I really want. I would like to
keep the object live until all work has been completed.

I have read a few things about sessions states etc, but don't really know
where to start, and how to make the class persist.

initially I had

public partial class CallOutDetail : System.Web.UI.Page
{
ExistingCallout Currentcallout;
int m_CalloutPK = 0;

protected void Page_Load(object sender, EventArgs e)
{
m_CalloutPK = 1212;
Currentcallout = new ExistingCallout(m_CalloutPK);


I have tried putting the Currentcallout in not postback i.e.

public partial class CallOutDetail : System.Web.UI.Page
{
ExistingCallout Currentcallout;
int m_CalloutPK = 0;

protected void Page_Load(object sender, EventArgs e)
{
m_CalloutPK = 1212;
if (!IsPostBack)
{
// first time
Currentcallout = new ExistingCallout(m_CalloutPK);
SetLabour();
SetMaterials();
}


Any pointers would be welcome

thanks

Andy
 
G

Guest

couple options....
both require that it be serialized

you can place it in the Page's viewstate...

private constant vs_callout="A";

protected CalloutType CurrentCallout{
get{return this.ViewState[vs_callout] as CalloutType;}
set{this.ViewState[vs_callout] = value;}
}

....or place it in the session
}
 
A

AAJ

thanks David


David Jessee said:
couple options....
both require that it be serialized

you can place it in the Page's viewstate...

private constant vs_callout="A";

protected CalloutType CurrentCallout{
get{return this.ViewState[vs_callout] as CalloutType;}
set{this.ViewState[vs_callout] = value;}
}

...or place it in the session
}



AAJ said:
Hi all

I have some experience in 'Windows' programming but I am new to Web
programming, I wonder if anyone can help.

I have a middle layer object that brings some data from a database class
.
The class reprsents a Callout, has lots of methods and properties and
manages the business logic..

I then have a html page (GUI layer) that creates an instance of a
callout,
and from the callout object, it displays some textfields, labour etc plus
some datagrids based on some collections it holds.

Everything works fine until the page refreshes, at which time the object
seems to be destroyed and then recreated.

I want to keep the object alive with its existing data, on the server,
and
connect back to it , ie. not create a new object each time. I know I
could
use my Callouts WriteDate event to persist the data back to the
SQLServer,
and then just re load it, but this isn't what I really want. I would like
to
keep the object live until all work has been completed.

I have read a few things about sessions states etc, but don't really know
where to start, and how to make the class persist.

initially I had

public partial class CallOutDetail : System.Web.UI.Page
{
ExistingCallout Currentcallout;
int m_CalloutPK = 0;

protected void Page_Load(object sender, EventArgs e)
{
m_CalloutPK = 1212;
Currentcallout = new ExistingCallout(m_CalloutPK);


I have tried putting the Currentcallout in not postback i.e.

public partial class CallOutDetail : System.Web.UI.Page
{
ExistingCallout Currentcallout;
int m_CalloutPK = 0;

protected void Page_Load(object sender, EventArgs e)
{
m_CalloutPK = 1212;
if (!IsPostBack)
{
// first time
Currentcallout = new ExistingCallout(m_CalloutPK);
SetLabour();
SetMaterials();
}


Any pointers would be welcome

thanks

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top