G
Guest
I've written several UserControls that contain different versions of a form
that users need to fill out. Depending on which role a user is logged in as,
I load the appropriate UserControl and add it to a panel on my WebForm. So
far, so good. However, when the form is posted back to the server, I'm
getting stuck.
I don't think I want to load the control into the panel again because then
all of the values that were set by the user before posting back will be lost.
Still, I have to get an instance of the control somehow.
I thought maybe I'd stuff the entire UserControl into the ViewState (the
user controls are not very big), but then I get an error message saying, "The
type 'ASP.MyDataEntryForm_ascx' must be marked as Serializable or have a
TypeConverter other than ReferenceConverter to be put in viewstate." I've put
a [Serializable] attribute on the control's class, but it doesn't seem to
help. The control only contains other WebControls, all of which can have
ViewState enabled.
Any ideas, or should I go for a completely different approach like
redirecting to different pages instead of loading different controls into a
single page? Thanks!
that users need to fill out. Depending on which role a user is logged in as,
I load the appropriate UserControl and add it to a panel on my WebForm. So
far, so good. However, when the form is posted back to the server, I'm
getting stuck.
I don't think I want to load the control into the panel again because then
all of the values that were set by the user before posting back will be lost.
Still, I have to get an instance of the control somehow.
I thought maybe I'd stuff the entire UserControl into the ViewState (the
user controls are not very big), but then I get an error message saying, "The
type 'ASP.MyDataEntryForm_ascx' must be marked as Serializable or have a
TypeConverter other than ReferenceConverter to be put in viewstate." I've put
a [Serializable] attribute on the control's class, but it doesn't seem to
help. The control only contains other WebControls, all of which can have
ViewState enabled.
Any ideas, or should I go for a completely different approach like
redirecting to different pages instead of loading different controls into a
single page? Thanks!