c*o 发帖数: 70 | 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? | n*********g 发帖数: 75 | 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?
| r***e 发帖数: 38 | 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?
| k****i 发帖数: 1072 | 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?
| c*o 发帖数: 70 | 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
| k****i 发帖数: 1072 | 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
| b********s 发帖数: 12 | 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
| k****i 发帖数: 1072 | 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.
| b********s 发帖数: 12 | 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
|
|