473,404 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Error while using 'ControlState' property in my custom control

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
--
Cheers,
Pavan
Dec 7 '05 #1
0 1529

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Alex Stevens | last post by:
I'd already posted this in microsoft.public.dotnet.framework.windowsforms and microsoft.public.dotnet.framework.windowsforms.controls to no avail so apologies for the cross-posting. Hi, I'm...
16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
6
by: Steve Amey | last post by:
Hi all I want to be able to throw a custom error up the call stack. I have looked around and it seems as though it's possible, but I can't get it to work :o( Below is some sample code. ...
5
by: Mark Olbert | last post by:
Tonight's episode of me beating my head bloody against the monitor was the result of ViewState/ControlState information not being available when CreateChildControls() gets called for a...
1
by: Don | last post by:
I'm getting the following exception displayed in the task list at design time for my project: "Code generation for property 'Controls' failed. Error was: 'Object reference not set to an...
2
by: Edward | last post by:
I am reading MSDN doc about Control's ViewState and ControlState. I got myself quite puzzled. I see that the Control class has four virtual functions: LoadControlState LoadViewState...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.