|
Rank: Member Groups: Member
Joined: 6/2/2008 Posts: 14
|
I'm trying to add and set the datepicker's style using a class collection. I have the datepicker rendered in a class such as:
Code: Visual Basic.NET
Private Sub DateControl_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
With DatePicker
.controlskinid = "none"
.daycellheight = "16"
.TitleRightArrowImageUrl = "DefaultSubMenuIcon"
.....
End With
And so forth...but the style is not being rendered correctly. Where should I place the styling or what's the best way of doing this? The ".style" attribute is also complaining that it's only a read-only...so how do I set its property? Thanks a lot.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Hi,
Try to do it before PreRender, for example, in the Init or Load event. PreRender is too late for the DatePicker control because the control itself relies on PreRender to do a number of things.
If you must use PreRender, do not use Pre_Render event, try override OnPreRender instead. Inside your version of OnPreRender, call your code first, then call base class's OnPreRender.
Thanks
|
|
Rank: Member Groups: Member
Joined: 6/2/2008 Posts: 14
|
Update: this has been fixed. Adding it in the load event works.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Hi, Here is a short sample:
Code: C#
private void Page_Load(object sender, System.EventArgs e)
{
DatePicker1.TitleRightArrowImageUrl = "00040102";
}
We verified it with a blank form having a single Calendar control. When you override OnPreRender, you must call the base class's OnPreRender. Otherwise the calendar will stop working. Thanks
|
|
Rank: Member Groups: Member
Joined: 6/2/2008 Posts: 14
|
Another quick question related to this topic.
Since I add the formatting of the datepicker dynamically, how do I get rid of the message in the front end, "The DateControl has no style settings. Right click to select styles". Is there a way to disable this?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Hi,
Unfortunately I am not aware of any way to disable that. It should not affect runtime behavior though.
Thanks
|
|