Welcome Guest Search | Active Topics | Sign In | Register

Add style to controls dynamically using class collection Options
The Menace
Posted: Tuesday, June 24, 2008 2:22:55 PM
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.


eo_support
Posted: Tuesday, June 24, 2008 2:28:20 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,097
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
The Menace
Posted: Friday, June 27, 2008 1:12:25 PM
Rank: Member
Groups: Member

Joined: 6/2/2008
Posts: 14
Update: this has been fixed. Adding it in the load event works.
eo_support
Posted: Friday, June 27, 2008 1:20:47 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,097
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
The Menace
Posted: Monday, July 21, 2008 11:44:21 AM
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?
eo_support
Posted: Monday, July 21, 2008 12:24:42 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,097
Hi,

Unfortunately I am not aware of any way to disable that. It should not affect runtime behavior though.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.