473,583 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.MinVal ue to DateTime.MaxVal ue)

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 CompositeCalend ar 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 CompositeCalend ar

b. Store properties in controlstate for CustomCalendar.

3. When the page is posted back

a. Load controlstate values into properties of CompositeCalend ar

b. Load controlstate values into properties of CustomCalendar

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

When I use, custom calendar (base control) alone, there was no problem, but
when I use CompositeCalend ar (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 1542

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

Similar topics

3
2400
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 writing a usercontrol which displays the typical two listboxes and the ability to move items from one to the other. The listboxes are populated...
16
7207
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
4994
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. I created the websetup and built the MSI, have the bundled version. Copied to webserver and ran Websetup.msi. Said I had to remove old version,...
6
1574
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. ------------------------------------------------------------ Public Class MainForm Public Sub Show Form Try
5
7247
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 CompositeControl. So, my question is, >>why<< isn't ViewState/ControlState available before CreateChildControls() gets called by the Framework? Is it just me,...
1
8350
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 instance of an object.'" I've traced the problem to a custom control I created that inherits from Inherits System.Windows.Forms.TextBox. In this custom...
2
5591
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 SaveControlState SaveViewState But a Control has only ViewState property but no ControlState.
2
19442
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 will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's...
0
2897
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 will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's...
0
7888
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7811
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8185
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5689
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3811
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3836
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1416
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.