ASP.Net对象生活 [英] ASP.Net Object Life

查看:60
本文介绍了ASP.Net对象生活的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个动态加载的控件,用于查询数据库并将结果填充到一个新对象中。


类人物

...班级物业

...班级方法

结束班级


作为新人的昏暗人物
Person.GetPersonInformation(Session(PersonId))


问题:即使在创建了

之后,Person对象仍将在回发后保留一个新的人物


问题:我认为回弹之间不存在状态

解决方案

re:


昏暗的人作为新人

Person.GetPersonInformation(Session(" PersonId"))


问题:Person对象将在回发后保留,即使在创建新Person之后



您是否尝试过调用Person 。完成后,请暂停()?


Juan T. Llibre,asp.net MVP

aspnetfaq.com: http://www.aspnetfaq.com/

asp.net faq: http://asp.net.do/faq/

foros de asp.net,en espa?ol: http://asp.net.do/foros/

===================================

< nj **** @ yahoo.com在留言新闻中写道:11 ********************** @ m79g2000cwm.googlegr oups.com ...


>我有一个动态加载的控件,用于查询数据库并将结果填充到一个新对象中。


类人员

..class属性

..类方法

结束班


昏暗的人为新Person

Person.GetPersonInformation(Session(" PersonId)))


问题:人物对象即使在创建了一个新人后,我也会坚持回帖。


问题:我认为状态不是在回发之间举行



实际上,我不确定你是否发布了足够的代码来说明你的

问题。

如果你是将此对象转换为Session然后再次从

Session再次访问它,为什么你会期望它不会在回发中持续存在

(这就是会话状态是什么对于)。如果你每次都需要一个新的对象,那么你应该考虑用新的对象替换Session中的那个。

Peter


-

联合创始人,Eggheadcafe.com开发者门户网站:
http://www.eggheadcafe.com

UnBlog:
http://petesbloggerama.blogspot.com


" nj **** @ yahoo.com"写道:


我有一个动态加载的控件,用于查询数据库并将结果填充到一个新对象中。
< br $>
班级人员

...班级物业

...班级方法

结束班级


作为新人的昏暗人物

Person.GetPersonInformation(会话(PersonId))


问题:人物对象将持续存在回帖后,即使在创建了一个新人之后,我也会这样做。


问题:我认为在回发之间没有举行状态


感谢您回复...


Juan,这是我自己的实例化的简单对象,因此我不是

有一个处置方法???


彼得,我不会在任何时候将对象保存到Session。以下是一些

步骤:

1. ASPXPage.LoadControl(" PersonControl.ascx")

2.调用Sub BuildPerson - 创建人员,检索年龄

3.回复并逐步完成

a。创造人 - 历史坚持


班级人物

物业年龄

公共职能GetPersonInformation()

...从数据库中获取年龄

...设置属性年龄

结束功能

结束班级


Sub BuildPerson

作为新人的昏暗人物

Person.GetPersonInformation()

昏暗年龄= Person.Age

End Sub


I have a dynamically loaded control that queries a database and fills
the results into a new object.

Class Person
...class properties
...class methods
End Class

Dim Person As New Person
Person.GetPersonInformation(Session("PersonId"))

Problem: Person Object will persist upon posting back, even after
creating a new Person

Question: I thought state is not held between postbacks

解决方案

re:

Dim Person As New Person
Person.GetPersonInformation(Session("PersonId"))

Problem: Person Object will persist upon posting back, even after creating a new Person

Have you tried calling Person.Dispose() when you''re done with it ?

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
===================================
<nj****@yahoo.comwrote in message news:11**********************@m79g2000cwm.googlegr oups.com...

>I have a dynamically loaded control that queries a database and fills
the results into a new object.

Class Person
..class properties
..class methods
End Class

Dim Person As New Person
Person.GetPersonInformation(Session("PersonId"))

Problem: Person Object will persist upon posting back, even after
creating a new Person

Question: I thought state is not held between postbacks



Actually, I am not sure you have posted sufficient code to illustrate your
problem.
If you are getting this object into Session and then accessing it again from
Session each time, why would you expect it NOT to persist across postbacks
(that''s what Session State is for). If you need a new object each time, then
you should consider replacing the one in Session with your new one.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"nj****@yahoo.com" wrote:

I have a dynamically loaded control that queries a database and fills
the results into a new object.

Class Person
...class properties
...class methods
End Class

Dim Person As New Person
Person.GetPersonInformation(Session("PersonId"))

Problem: Person Object will persist upon posting back, even after
creating a new Person

Question: I thought state is not held between postbacks


Thanks for writing back...

Juan, This is my own simple object I instantiate, therefore I do not
have a dispose method???

Peter, I''m not saving the object to Session at anytime. Here are some
steps:
1. ASPXPage.LoadControl("PersonControl.ascx")
2. Call Sub BuildPerson - Create Person, Retrieve Age
3. Post Back and step through
a. Create Person --Age persists

Class Person
Property Age
Public Function GetPersonInformation()
...get age from database
... set property Age
End Function
End Class

Sub BuildPerson
Dim Person As New Person
Person.GetPersonInformation()
dim age=Person.Age
End Sub


这篇关于ASP.Net对象生活的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆