473,408 Members | 1,676 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,408 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 6498
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.