473,246 Members | 3,729 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,246 software developers and data experts.

Get the current theme name at design time.

Hi all,

Is there a way to get the current theme name at design time?

I'm trying to write a custom control for which I need to use images from the
current theme. I have asigned a theme to the page as well as in the
web.config.

The control looks ok at run time but when viewed in the Visual Studio
designer it cannot pick up the current theme.

Thanks in advance,
Greg.
May 24 '07 #1
11 6493
On 24 mei, 11:40, "greg" <g...@metastorm.no.spam.comwrote:
Hi all,

Is there a way to get the current theme name at design time?

I'm trying to write a custom control for which I need to use images from the
current theme. I have asigned a theme to the page as well as in the
web.config.

The control looks ok at run time but when viewed in the Visual Studio
designer it cannot pick up the current theme.

Thanks in advance,
Greg.
Page.Theme

May 24 '07 #2
>
Page.Theme
Hi Veerle,

Page.Theme at design time is not available.

Thanks,
Greg.
May 24 '07 #3
re:
Is there a way to get the current theme name at design time?
You probably can get around this problem by building a string path to the correct directory.

You know all the themes reside under the App_Themes directory :
WebSite
\App_Themes
\ BlueTheme
Controls.skin
BlueTheme.css
\PinkTheme
Controls.skin
PinkTheme.css

If you set the Theme in the querystring :

Protected void Page_PreInit(object sender, EventArgs e)
{
switch (Request.QueryString["theme"])
{
case "Blue":
Page.Theme = "BlueTheme";
break;
case "Pink":
Page.Theme = "PinkTheme";
break;
}
}

....you can build a path to the correct directory you want to use for the images.

For a relative path to the directory for the current theme:

Page.AppRelativeVirtualPath + "/" & App_Themes + "/" + Request.QueryString["theme"]) +"/"

For the fully qualified path to the directory for the current theme :

string fullappname = Request.Url.Host
string fullpath = "http://" + fullappname + Request.ApplicationPath + "/" + App_Themes + "/" +
Request.QueryString["theme"])+"/"

Please double check the syntax, as I usually work in VB.NET...


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"greg" <gr**@metastorm.no.spam.comwrote in message news:eJ**************@TK2MSFTNGP06.phx.gbl...
Hi all,

Is there a way to get the current theme name at design time?

I'm trying to write a custom control for which I need to use images from the current theme. I have
asigned a theme to the page as well as in the web.config.

The control looks ok at run time but when viewed in the Visual Studio designer it cannot pick up
the current theme.

Thanks in advance,
Greg.

May 24 '07 #4
You probably can get around this problem by building a string path to the
correct directory.

You know all the themes reside under the App_Themes directory :
......
If you set the Theme in the querystring :

How would that work at design time?
I don think there is a way to set the query string while you are viewing
your page in Visual Studio (design time).
May 24 '07 #5
re:
!I don think there is a way to set the query string while you are viewing
!your page in Visual Studio (design time).

You wouldn't have to, would you ?

*You* don't need to know the path; the application's *users* do.

The code I posted ( which might need some checking, since C# isn't my strongest language )
assures that the *users* of the site get the correct path to the theme directory in use.

I assume that developers know what images they want to append to the path returned by that code.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Gregory Gasteratos" <gg*********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>You probably can get around this problem by building a string path to the correct directory.

You know all the themes reside under the App_Themes directory :
......
If you set the Theme in the querystring :
How would that work at design time?
I don think there is a way to set the query string while you are viewing your page in Visual
Studio (design time).


May 24 '07 #6
You wouldn't have to, would you ?
>
*You* don't need to know the path; the application's *users* do.
In my case I would, as my custom control uses a glyph that needs to be
displayed at design time as well as run time. That glyph is different
depending on the theme.
May 25 '07 #7
"greg" <gr**@metastorm.no.spam.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>You wouldn't have to, would you ?

*You* don't need to know the path; the application's *users* do.

In my case I would, as my custom control uses a glyph that needs to be
displayed at design time as well as run time. That glyph is different
depending on the theme.
But only you (i.e. the developer) sees design time... So long as everything
displays properly for your users (i.e. at run time), how can it possibly
matter to you whether something "looks nice" at design time...?
--
http://www.markrae.net

May 25 '07 #8
But only you (i.e. the developer) sees design time... So long as
everything displays properly for your users (i.e. at run time), how can it
possibly matter to you whether something "looks nice" at design time...?
Developing a third paty control lybrary for others to use that wouldn't go
down very well.

I guess the question is not whether it matters to me or not. The question is
whether one can get the theme name at design time.

Digging into MSDN I found IThemeResolutionService and ThemeProvider. But I
couldn't find any example of how to use them.

Thanks for your replies.
Greg.
May 25 '07 #9
re:
!my custom control uses a glyph that needs to be displayed at design time

Why ?

Design is design and runtime is runtime.
You can't expect runtime functionality at design time.

A similar example is using a querystring.

You don't need to see a querystring at design time.
You only need to be able to program against it.

re:
!That glyph is different depending on the theme

I had gathered as much.
You'll have different glyphs in each theme's directory, right ?

Then, all you need to know is the path to the directory which contains
the specific glyph you're interested in displaying with the active theme.

I think what I outlined should suffice, and don't quite understand
why you'd need to actually see a glyph at design time.

At design time, themes are neither enabled nor displayed.
That's done at runtime.

As a developer, all you need to do is insure programmability.
If it works...that's all you need as a developer.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"greg" <gr**@metastorm.no.spam.comwrote in message news:%2****************@TK2MSFTNGP06.phx.gbl...
>You wouldn't have to, would you ?

*You* don't need to know the path; the application's *users* do.

In my case I would, as my custom control uses a glyph that needs to be displayed at design time as
well as run time. That glyph is different depending on the theme.

May 25 '07 #10
re:
!Developing a third paty control lybrary for others to use that wouldn't go down very well.

Why not ?

Won't you will be supplying the different themes and glyphs ?
Won't you be placing them in the correct directories ?

If you design a control which displays different glyphs depending on which
theme is active, you can't expect your control's buyers to develop them, can you ?

re:
!I guess the question is not whether it matters to me or not

Now I understand better, although If I had a choice between a control looking good
esthetically, at design time, and having a feature of a software product I wrote work
as expected at runtime, I'd definitely pick the latter.

But, it's your control and your approach should be determined by you.

I'm sorry if the solution I propose isn't appealing/acceptable to you.
It does work, though, and it has the right price.

:-)


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"greg" <gr**@metastorm.no.spam.comwrote in message news:Oi**************@TK2MSFTNGP04.phx.gbl...
>But only you (i.e. the developer) sees design time... So long as everything displays properly for
your users (i.e. at run time), how can it possibly matter to you whether something "looks nice"
at design time...?

Developing a third paty control lybrary for others to use that wouldn't go down very well.
I guess the question is not whether it matters to me or not. The question is whether one can get
the theme name at design time.

Digging into MSDN I found IThemeResolutionService and ThemeProvider. But I couldn't find any
example of how to use them.

Thanks for your replies.
Greg.

May 25 '07 #11
"greg" <gr**@metastorm.no.spam.comwrote in message
news:Oi**************@TK2MSFTNGP04.phx.gbl...
Developing a third paty control lybrary for others to use that wouldn't go
down very well.
It wouldn't bother me in the slightest, as I (almost) never use Design view
anyway...
--
http://www.markrae.net

May 25 '07 #12

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

Similar topics

7
by: Terry Olsen | last post by:
I paste the following code into each project to get XP theme support. 'Add this at the beginning of any program to enable Windows XP Visual Styles <System.STAThread()> Public Shared Sub Main() If...
4
by: Ben | last post by:
Hi, I'm using images in my menu control. I have my menu setup based on this example: http://msdn2.microsoft.com/en-US/library/system.web.ui.webcontrols.menuitembinding.imageurlfield(VS.80).aspx ...
0
by: ThazKool | last post by:
I would like to use RegisterStartupScript to load some css from the current theme. How do I get the path to the current theme folder.
0
by: Brant Estes | last post by:
So try this. Create a new ASP.NET 2.0 website. Add a theme. Add a skin to the theme. In your web.config, add the <pages theme="MyTheme" styleSheetTheme="MyTheme" /tag under your system.web...
1
by: grexican | last post by:
Hello, I'm working with some third-party JS code, such as mootools and moo.fx, among a few others. They have some really nice "flashy" features, such as fading from one color to another to...
2
by: teo | last post by:
hallo, for a pop-up menu (it's a 'ContextMenuStrip' control) I 'd like to set the current System font Currently the ContextMenuStrip has the MS San Sarif font and the 8,25 size but I'd like...
4
by: Neil Jones | last post by:
Hello, I would like to create my own theme(s) for a couple of my own blog sites. I am hoping a few better themes could bring lot more readers. So far, I have stayed with the default wordpress...
1
by: Henry Stock | last post by:
I am having trouble referencing a theme in my ASP.NET project. I was following a model that allowed for multiple themes. So The theme that I have is stored in named "Base" under the App_Theme...
8
by: Mateusz Viste | last post by:
Hi, I'm not sure if my question is really related to JavaScript, so please excuse me if that's not the case (and maybe you guys would have an idea what's the cause is and where could I ask)... ...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
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: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...

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.