By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,909 Members | 2,016 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,909 IT Pros & Developers. It's quick & easy.

Get the current theme name at design time.

P: n/a
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
Share this Question
Share on Google+
11 Replies


P: n/a
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

P: n/a
>
Page.Theme
Hi Veerle,

Page.Theme at design time is not available.

Thanks,
Greg.
May 24 '07 #3

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
"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 discussion thread is closed

Replies have been disabled for this discussion.