Calendar ID attribute not equal to ClientId

WebControls generally render the Id attribute as the ClientId value so that they can be unique from a DOM perspective. The Calendar Control does not seem to follow this.

For example, if you have a Calendar Control Calendar1 in an ascx page WebUserControl, instead of rendering the Id as WebUserControl1_Calendar1 on the parent page, it simply renders it as Calendar1.

When developing a custom webcontrol that “looks at” other controls, it becomes impossible to use the getElementById property on the the calendar control as the ID rendered is different from what you are expecting.

The workaround I used is to embed the Calendar control in a Panel control and use the ID of the Panel control. I realize you could hard code values instead of doing this but my webcontrol needs to use the getElementById method to get different controls on a container.

Is there a reason behind this?

No Comments