A
AC
I've got a page which, when it initially loads (i.e. IsPostBack ==
false), loads all my application's users into one list and all the
roles into another. If it is a postback, it loads details of the
selected user into a bunch of literals, textboxes, etc. So far, so
good.
Generally, it goes like this:
Page_Load
{
if (IsPostBack)
// load user UserList.SelectedValue
else
{
// populate UserList and RoleList
}
}
Then I added an "Apply changes" button and handled the "if something
changed update user" stuff in the button's _Click event.
Button_Click
{
// if something changed, update user
}
However, the _Click event occurs after the Page_Load event, so before
all the "if something changed" code gets executed, all the fields are
set back to their original pre-changed values.
Clearly, I'm still in Windows Forms mode and haven't quite got to
grips with web forms... can anyone shed a bit of light please? I
think it's mostly just a case of reorganising but it feels like I
might've missed a trick...
Thanks for your help!
false), loads all my application's users into one list and all the
roles into another. If it is a postback, it loads details of the
selected user into a bunch of literals, textboxes, etc. So far, so
good.
Generally, it goes like this:
Page_Load
{
if (IsPostBack)
// load user UserList.SelectedValue
else
{
// populate UserList and RoleList
}
}
Then I added an "Apply changes" button and handled the "if something
changed update user" stuff in the button's _Click event.
Button_Click
{
// if something changed, update user
}
However, the _Click event occurs after the Page_Load event, so before
all the "if something changed" code gets executed, all the fields are
set back to their original pre-changed values.
Clearly, I'm still in Windows Forms mode and haven't quite got to
grips with web forms... can anyone shed a bit of light please? I
think it's mostly just a case of reorganising but it feels like I
might've missed a trick...
Thanks for your help!