avatar
c*o
1
Once a button is clicked on a web form, a Post message will send to the
server, where the code Page_Load () will be executed. However, I don't want to
initialize the Profile p again, so I put it is !IsPostBack(). But in this
case, the p will be null in the button's click event handling function
lkbtEmail_Click(). If I put initProfile() out of !IsPostBack(). It works. But
the initProfile() is a procedure which get a lot of information from the
database. I just want to do it once. How can I do it?
avatar
n*g
2
Session?
ViewState?

【在 c*o 的大作中提到】
: Once a button is clicked on a web form, a Post message will send to the
: server, where the code Page_Load () will be executed. However, I don't want to
: initialize the Profile p again, so I put it is !IsPostBack(). But in this
: case, the p will be null in the button's click event handling function
: lkbtEmail_Click(). If I put initProfile() out of !IsPostBack(). It works. But
: the initProfile() is a procedure which get a lot of information from the
: database. I just want to do it once. How can I do it?

avatar
r*e
3
Try to do initProfile() in Page_Init()

to
But

【在 c*o 的大作中提到】
: Once a button is clicked on a web form, a Post message will send to the
: server, where the code Page_Load () will be executed. However, I don't want to
: initialize the Profile p again, so I put it is !IsPostBack(). But in this
: case, the p will be null in the button's click event handling function
: lkbtEmail_Click(). If I put initProfile() out of !IsPostBack(). It works. But
: the initProfile() is a procedure which get a lot of information from the
: database. I just want to do it once. How can I do it?

avatar
k*i
4
Each time a request comes,not matter it's a new request or postback,a new
application object will be created(or from application object pool).Postback
request only restore the info stored in the viewstate bag.So store ur profile
somewhere like session,application,viewstate,cache,cookie,hidden field and
retrieve it back.

to
But

【在 c*o 的大作中提到】
: Once a button is clicked on a web form, a Post message will send to the
: server, where the code Page_Load () will be executed. However, I don't want to
: initialize the Profile p again, so I put it is !IsPostBack(). But in this
: case, the p will be null in the button's click event handling function
: lkbtEmail_Click(). If I put initProfile() out of !IsPostBack(). It works. But
: the initProfile() is a procedure which get a lot of information from the
: database. I just want to do it once. How can I do it?

avatar
c*o
5
Your comments are very helpful. Would you please recommend any in-depth
illustration links or books about this issue? Thank you soooooooooo much!

profile
want

【在 k****i 的大作中提到】
: Each time a request comes,not matter it's a new request or postback,a new
: application object will be created(or from application object pool).Postback
: request only restore the info stored in the viewstate bag.So store ur profile
: somewhere like session,application,viewstate,cache,cookie,hidden field and
: retrieve it back.
:
: to
: But

avatar
k*i
6
msdn,"essential asp.netwith examples in c#,etc.

pool).Postback
this
works.

【在 c*o 的大作中提到】
: Your comments are very helpful. Would you please recommend any in-depth
: illustration links or books about this issue? Thank you soooooooooo much!
:
: profile
: want

avatar
b*s
7
Session or page cache would be the good choice. For page cache,you can check
"Cache Services" chapter at http://www.asp.net/Tutorials/quickstart.aspx .
Cookie has limited size and some security issue.

pool).Postback
this
works.

【在 c*o 的大作中提到】
: Your comments are very helpful. Would you please recommend any in-depth
: illustration links or books about this issue? Thank you soooooooooo much!
:
: profile
: want

avatar
k*i
8
Sometimes hidden field is a better choice.Think about what happend if the user
hit the back button in IE and they want to rollback to previous state.

new
and
the
the
declare

【在 b********s 的大作中提到】
: Session or page cache would be the good choice. For page cache,you can check
: "Cache Services" chapter at http://www.asp.net/Tutorials/quickstart.aspx .
: Cookie has limited size and some security issue.
:
: pool).Postback
: this
: works.

avatar
b*s
9
Could be. I prefer to use page cache or session.Page cache can store any
object as you like.This is design choice. Let us leave it to cio.

user
check
much!
don't
function

【在 k****i 的大作中提到】
: Sometimes hidden field is a better choice.Think about what happend if the user
: hit the back button in IE and they want to rollback to previous state.
:
: new
: and
: the
: the
: declare

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。