1

I built a CompositeControl in ASP.Net and now I'm having trouble maintaining the ViewState of 3 instances of the Control on the hosting page. My CompositeControl has a property "HeaderText" and all 3 instances of my CompositeControl do have the value of the first control instance on the page.

For example: If the first control has HeaderText = "Test 1", then all other controls have also HeaderText = "Test 1".

During debugging I found out that the set operator of the property is called 2 times. When I trace the set operator with Debug.WriteLine() outputs then the output looks like:

HeaderText of Control 1 = "Test 1"
HeaderText of Control 2 = "Test 2"
HeaderText of Control 3 = "Test 3"
HeaderText of Control 1 = "Test 1" <-- Why is the set operator called 2 times for each Control?
HeaderText of Control 2 = "Test 1"
HeaderText of Control 3 = "Test 1"
Gerrit Horeis
  • 541
  • 5
  • 14

1 Answers1

0

Just in case someone else is experiencing this behavior: I turned on the debugging of "external code" and figured out that I accidentally added the property to the skin file, too. Therefore the set operator of the HeaderText was called 2 times...hard to find this error.

Gerrit Horeis
  • 541
  • 5
  • 14