|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problem with ViewStateI'm building a custom control that contain a property that is a custom collection. This custom collection return as element an object of class A. Class A contain a property that is of the same type of the collection up. The problem is I use ViewState to mantain status of the collection but at each postback it become null. ViewState works well for other property of the control. I've also tried to serialize the collection into a file and works too. How to solve? Thanks, Matteo Migliore. When during postback are you trying to access your ViewState? If you try
to access it in Page_Init, then it will be null, as ASP.NET has not yet reconstructed it for you. -Brock DevelopMentor http://staff.develop.com/ballen Show quoteHide quote > Hi. > > I'm building a custom control > that contain a property that is a > custom collection. > This custom collection return > as element an object of class A. > Class A contain a property that is > of the same type of the collection up. > The problem is I use ViewState to > mantain status of the collection but > at each postback it become null. > ViewState works well for other > property of the control. > I've also tried to serialize the > collection into a file and works too. > How to solve? > > Thanks, > Matteo Migliore. Hi Brock.
> When during postback are you trying to access your ViewState? If you try No, I try to access it into OnLoad event.> to access it in Page_Init, then it will be null, as ASP.NET has not yet > reconstructed it for you. For another property (of type of the class A) that use ViewState there aren't problem. Matteo Migliore. > No, I try to access it into OnLoad event. Well, it's odd that it's null for you then. OnLoad should have the ViewState reconstructed for you. I suppose without more info on what's going on, I can't help in finding out what the problem is. -Brock DevelopMentor http://staff.develop.com/ballen Can you post the code for:
1. Attributes to the control class 2. The property been exposed (type and attributes) as in the main control 3. The methods LoadViewState and SaveViewState 4. The hierarchy of and attributes to the custom collection class. -- Cheers, Gaurav Vaish http://www.mastergaurav.org http://mastergaurav.blogspot.com -------------------------------- Hi.
Thank you in advance. > Can you post the code for: The only attribute I used is DesingerAttribute> 1. Attributes to the control class but it not useful to solve the problem :-D. > 2. The property been exposed (type and attributes) as in the main I've not implemented.> control > 3. The methods LoadViewState and SaveViewState I use viewstate in this way: public COLLECTION_TYPE Property1 { get { return ViewState["Property1"] as COLLECTION_TYPE; } set { ViewState["Property1"] = value; } } > 4. The hierarchy of and attributes to the custom collection class. What I've to post? :-DI don't understand. Matteo Migliore.
Show quote
Hide quote
"MasterGaurav" <gaurav.va***@gmail.com> wrote in message You might try adding this bit of code to your page.news:1114666067.739955.136320@g14g2000cwa.googlegroups.com... > Can you post the code for: > > 1. Attributes to the control class > 2. The property been exposed (type and attributes) as in the main > control > 3. The methods LoadViewState and SaveViewState > 4. The hierarchy of and attributes to the custom collection class. > > > -- > Cheers, > Gaurav Vaish > http://www.mastergaurav.org > http://mastergaurav.blogspot.com > -------------------------------- Protected Overrides Function SaveViewState() As Object Return MyBase.SaveViewState() End Function Protected Overrides Sub LoadViewState(savedState As Object) If Not (savedState Is Nothing) Then MyBase.LoadViewState(savedState) End If End Sub
How to implement a property like ControlToValidate property?
Adding Event Handler to Dynamically added Controls Copy Paste label textbox aspx code TabStrip/Multipage using UserControl (.ascx) contained within a UserControl(.ascx) createuserwizard refuese to add users due to password Treeview IE Web Control and Mac Client side dynamic graphing problem TabStrip sample displays text only Any Descent Gantt Chart ASP.NET Webform Components? Textbox error |
|||||||||||||||||||||||