By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 852 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Persistance

P: n/a
I have some classes that contain my objects...say..... Client...with all his
properties, Methods & Events. I use this on my web pages like this.
Dim MyClient as New Client(IdCorporation)

This because I need the information of that client as a reference.

Then I use:

If not page.IsPostBack then

Dim MyOtherClient as New Client ()
This is created just to use a function from that class:
MyOtherClient.Add (Name, Address, City, Zip, Phone)

Endif

The problem is that when a postback occurs...MyOtherClient = MyClient.

How should this be handled?

Thanks
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"CCORDON" <tc******@hotmail.com> wrote
I have some classes that contain my objects...say..... Client...with all his
properties, Methods & Events. I use this on my web pages like this.

Dim MyClient as New Client(IdCorporation)

This because I need the information of that client as a reference.

Then I use:

If not page.IsPostBack then

Dim MyOtherClient as New Client ()
This is created just to use a function from that class:
MyOtherClient.Add (Name, Address, City, Zip, Phone)

Endif

The problem is that when a postback occurs...MyOtherClient = MyClient.

How should this be handled?

What you posted seems impossible, no where are the two related to eachother
in your posted code. Perhaps you need to show more of what you are using....

LFS
Nov 21 '05 #2

P: n/a
Here is the code. Thank you for your help

Imports Vivo.DBAccess

Public Class CorporacionesMod

Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Protected WithEvents lblUserInfo As System.Web.UI.WebControls.Label

Protected WithEvents cmdLogOff As System.Web.UI.WebControls.ImageButton

Protected WithEvents RequiredFieldValidator2 As
System.Web.UI.WebControls.RequiredFieldValidator

Protected WithEvents txtNombre As System.Web.UI.WebControls.TextBox

Protected WithEvents cmdSave As System.Web.UI.WebControls.Button

Protected WithEvents ValidationSummary1 As
System.Web.UI.WebControls.ValidationSummary

'NOTE: The following placeholder declaration is required by the Web Form
Designer.

'Do not delete or move it.

Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

Private Shared objCorporacion As Corporacion

Private Shared MyUser As New User

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

If Session("LoggedOn") = False Then

Response.Redirect("../UserLogin.aspx")

Exit Sub

End If

MyUser = CType(Session("User"), User)

Dim MyCorp As New Corporacion(MyUser.IdCorporacion)

lblUserInfo.Text = MyUser.NombreCompleto & "<BR>" & MyCorp.Nombre

If MyUser.Super = False Then

Response.Redirect("NoAccess.aspx")

End If

If Not (Page.IsPostBack) Then

objCorporacion = New Corporacion(Request.Params("IdCorporacion"))

txtNombre.Text = objCorporacion.Nombre

End If

End Sub

Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdSave.Click

Session("ResultMessage") = objCorporacion.Update(objCorporacion.ID,
txtNombre.Text)

Response.Redirect("Result.aspx?RedirectPage=Corpor aciones.aspx")

End Sub

Private Sub cmdLogOff_Click(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles cmdLogOff.Click

Session("LoggedOn") = False

Session.Abandon()

Response.Redirect("../Gracias.aspx")

End Sub

End Class

Thanks,

"CCORDON" <tc******@hotmail.com> wrote in message
news:uO**************@TK2MSFTNGP11.phx.gbl...
I have some classes that contain my objects...say..... Client...with all
his properties, Methods & Events. I use this on my web pages like this.
Dim MyClient as New Client(IdCorporation)

This because I need the information of that client as a reference.

Then I use:

If not page.IsPostBack then

Dim MyOtherClient as New Client ()
This is created just to use a function from that class:
MyOtherClient.Add (Name, Address, City, Zip, Phone)

Endif

The problem is that when a postback occurs...MyOtherClient = MyClient.

How should this be handled?

Thanks

Nov 21 '05 #3

P: n/a

"CCORDON" <tc******@hotmail.com> wrote
Here is the code. Thank you for your help


OK, how have you determined the problem?
The problem is that when a postback occurs...MyOtherClient = MyClient.


I did not see any assignment like that in the code you posted. The obvious
conclusion is that the two were not made equal to eachother, so I have to
ask, how are you determining that they are equal?

LFS
Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.