473,322 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Theming custom created WebParts in ASP.NET 2.0

I have created my own WebPart using code, it is not derived from a UserControl.
Inside this WebPart I create a Calendar Control and add it to the WebParts
Control collection.

Now I want to apply a theme to this Calendar that is inside my WebPart. How
do I do that? I have created a theme and added a definition for a calendar.
The theme is applied to a calendar that is not inside the WebPart, but it is
not applied to the one inside.
Nov 19 '05 #1
5 1297
Hi c_kimbell,

Welcome to MSDN newsgroup.
As for the custom WebPart with a Calendar inside it, is it possible that we
define a public property on the Custom webPart which represent the Theme of
the inside Calendar control? Then, we any one assign a new value for this
property, the nested calendar's Theme value will be changed accordingly.

In addition, for .NET 2.0 and VS.NET whidbey beta issues, I suggest you
also try posting in the following web forum:

http://forums.microsoft.com/msdn/

since there are some other experienced members who may have some good ideas.

Thank you,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #2
Thanks for suggesting the ASP.NET forums, I have posted there now as well.

Here are some more details on what I have tried;
1. On the webpart I have exposed the Calendar as a property with the name
FromCalendar.
2. I have added the following to the .skin file

<%@ Register Assembly="IMK.WebParts" Namespace="IMK.WebParts"
TagPrefix="IMK" %>

<IMK:IMKDateWebPart runat="server">
<FromCalendar BackColor="#FFFFCC">
<SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
<TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt"
ForeColor="#FFFFCC" />
</FromCalendar>
</IMK:IMKDateWebPart>

Am I on the right track?

"Steven Cheng[MSFT]" wrote:
Hi c_kimbell,

Welcome to MSDN newsgroup.
As for the custom WebPart with a Calendar inside it, is it possible that we
define a public property on the Custom webPart which represent the Theme of
the inside Calendar control? Then, we any one assign a new value for this
property, the nested calendar's Theme value will be changed accordingly.

In addition, for .NET 2.0 and VS.NET whidbey beta issues, I suggest you
also try posting in the following web forum:

http://forums.microsoft.com/msdn/

since there are some other experienced members who may have some good ideas.

Thank you,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #3
Hi c_kimbell,

Thanks for your followup.
As you mentioned that
=================
1. On the webpart I have exposed the Calendar as a property with the name
FromCalendar.
2. I have added the following to the .skin file

<%@ Register Assembly="IMK.WebParts" Namespace="IMK.WebParts"
TagPrefix="IMK" %>

<IMK:IMKDateWebPart runat="server">
<FromCalendar BackColor="#FFFFCC">
<SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
<TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt"
ForeColor="#FFFFCC" />
</FromCalendar>
</IMK:IMKDateWebPart>
=======================

I'm not sure whether this will cause error since I haven't tested it.
However, IMO, I'd prefer expose a single string property on my custom web
control which represent the nested child calendar's Theme(or
stylesheettheme). Since the ASP.NET 2.0 's Theme are mostly for those
simple type properteis (such as string, int), I think just exposing a
single string type property will be much better). You can do the actual
Theme adjusting in the Property's Setter method.
How do you think ?

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #4
I get your point about using simple strings. One thing though, say you expose
a color, this can be specified using a name like 'Red' or it may be specified
using hex notation, like '#FFCC66'. The controls require a Color object, how
does one map between the different representations and the Color object. Are
there any utility classes I can use?

I have now done a bit more experimenting. If I declaratively add the webpart
to a webpartzone, then the theme is correctly applied. If I add the same
webpart to the zone using a catalog, the style is not applied. The catalog
I'm adding from is a custom created one, not one of the predefined types.

Any suggestions?

"Steven Cheng[MSFT]" wrote:
Hi c_kimbell,

Thanks for your followup.
As you mentioned that
=================
1. On the webpart I have exposed the Calendar as a property with the name
FromCalendar.
2. I have added the following to the .skin file

<%@ Register Assembly="IMK.WebParts" Namespace="IMK.WebParts"
TagPrefix="IMK" %>

<IMK:IMKDateWebPart runat="server">
<FromCalendar BackColor="#FFFFCC">
<SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
<TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt"
ForeColor="#FFFFCC" />
</FromCalendar>
</IMK:IMKDateWebPart>
=======================

I'm not sure whether this will cause error since I haven't tested it.
However, IMO, I'd prefer expose a single string property on my custom web
control which represent the nested child calendar's Theme(or
stylesheettheme). Since the ASP.NET 2.0 's Theme are mostly for those
simple type properteis (such as string, int), I think just exposing a
single string type property will be much better). You can do the actual
Theme adjusting in the Property's Setter method.
How do you think ?

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #5
Hi c_kimbell,

For those Color field, the ASP.NET runtime's ControlParser will help parse
the property value into the correct object instance. And for Color, there
is the ColorTranslator class which can be used from convert string color
value to System.Drawing.Color instance. For example:

string htmlColor = "Blue";
//or string htmlColor = "#3344ee";
// Translate htmlColor to a GDI+ Color structure.
Color myColor = ColorTranslator.FromHtml(htmlColor);

For the applying theme for custom created catalog's webpart, I'm not sure
whether this is ok. As far as I know, since the ASP.NET2.0 runtime apply
theme for controls in the page's PreInit event, so any change on Theme
after that event (for example in Page_load ..., post back event) will not
work in the first loading....

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #6

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

Similar topics

2
by: sstrangee | last post by:
Maybe I don't get the whole theming thing... but here is what I'm trying to do: I have a App_Themes directory with a Theme named "Standard." Under this theme a CSS named "standard.css" and also...
1
by: John | last post by:
Hi I have created custom membership/role/profile providers as per the web.config below. My questions are; 1. Have I defined them correctly? 2. How can I make the Login and Create User...
2
by: ryan.mclean | last post by:
Hello all, Can I add custom verbs to ascx webparts? I have seen good examples where the webpart is a custom control thingy that inherits from System.Web.UI.WebControls.WebParts, then overrides...
3
by: Mark Leistner | last post by:
I am having problems getting a gridview to bind to custom objects under any non-full trust level. I created a test project to verify what I am seeing isn't a side effect of other code in my...
0
by: apenly | last post by:
Hi all- I'm trying to Render a TreeView in a custom control, but I'm receiving a NullReferenceException at runtime. If I put the TreeView on the page it works fine, but as soon as I try to...
0
by: shane.niebergall | last post by:
Hi - I've been able to create my own webparts as a custom control, by compiling as a class library and then importing the dll on my asp.net page. However, I do appreciate the convenience of the...
5
by: gerry | last post by:
I am trying to create a custom container control that will only ever contain a specific type of control. At design time, when a control of a different type is added to the container I would like...
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
0
by: vegetable21 | last post by:
Hi all, I've been having an issue with my webparts for some time now, i'll try and explain it as best as i can: ASP.NET website using webparts and forms authentication. Multiple custom...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.