Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Error while using 'ControlState' property in my custom control

Reply
Thread Tools

Error while using 'ControlState' property in my custom control

 
 
Pavan
Guest
Posts: n/a
 
      12-07-2005
My name is Pavan and I am a software engineer working on ASP .Net web
development.



Currently I am using .Net 2.0 Professional Edition to develop my web pages.



I have a problem



I have created custom calendar control, that will display dates between
given date range (By default from DateTime.MinValue to DateTime.MaxValue)



The main properties for this control is:



1. MinDate

2. Max Date and

3. SelectedDate



I need to retain their values across postbacks.



Initially I have used ViewState bag to do so, but turning off the ViewState
breaks my control.


I came to know that, we can use ‘ControlState’ property instead.

I have done the same, and it worked fine.

After creating this control, I have created one more custom control (named
as composite calendar) using this custom calendar.


My composite calendar has same properties as custom calendar has, so I have
used ‘ControlState’ even for CompositeCalendar control.


Now the error is



When page gets loaded for the first time, there was no problem and page was
displayed as desired.



But when I try to postback the page, it is throwing an error:

'COLLECTION WAS MODIFIED AFTER THE ENUMERATOR WAS INSTANTIATED'

The flow is:

1. When the page loads for the first time, the page gets executed
normally.

2. The sequence of execution of this process is

a. Store properties in controlstate for CompositeCalendar

b. Store properties in controlstate for CustomCalendar.

3. When the page is posted back

a. Load controlstate values into properties of CompositeCalendar

b. Load controlstate values into properties of CustomCalendar



The process was executed properly, but after execution of ‘LoadControlState’
method, system has thrown the above error.



When I use, custom calendar (base control) alone, there was no problem, but
when I use CompositeCalendar (which internally uses CustomCalendar and other
controls), I got the above problem.



I have no clue, why it is happening and some of the sites stated that it is
because of a bug in Beta 2.



Please suggest me the possible solution.


--
Cheers,


Pavan
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting the value of a Master page's control's property using a property of the Master page Nathan Sokalski ASP .Net 25 03-04-2010 03:42 AM
Error while using 'ControlState' property in my custom control =?Utf-8?B?UGF2YW4=?= ASP .Net 0 12-07-2005 10:46 AM
Custom Control : One custom property to array of controls anon ASP .Net Web Controls 0 01-15-2005 11:32 AM
Keep custom property-value in custom rendered control Rob Joosen ASP .Net Building Controls 0 05-12-2004 11:56 AM
ControlDesigner not invoked on custom control when control is rendered within another custom control Matt Sokol ASP .Net Building Controls 2 08-07-2003 07:13 AM



Advertisments