473,725 Members | 2,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6527
On 24 mei, 11:40, "greg" <g...@metastorm .no.spam.comwro te:
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(ob ject sender, EventArgs e)
{
switch (Request.QueryS tring["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.AppRelativ eVirtualPath + "/" & App_Themes + "/" + Request.QuerySt ring["theme"]) +"/"

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

string fullappname = Request.Url.Hos t
string fullpath = "http://" + fullappname + Request.Applica tionPath + "/" + App_Themes + "/" +
Request.QuerySt ring["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.comwro te in message news:eJ******** ******@TK2MSFTN GP06.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*********@ho tmail.comwrote in message
news:%2******** ********@TK2MSF TNGP03.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.comwro te in message
news:%2******** ********@TK2MSF TNGP06.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 IThemeResolutio nService 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.comwro te in message news:%2******** ********@TK2MSF TNGP06.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

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

Similar topics

7
4304
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 OSFeature.Feature.IsPresent(OSFeature.Themes) Then System.Windows.Forms.Application.EnableVisualStyles() End If Application.DoEvents() 'This must be here, otherwise buttons won't stylize System.Windows.Forms.Application.Run(New Form1) End Sub...
4
3410
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 I have a theme and right now, the theme structure looks like... App_Themes --Authenticated ----Images ------Menu
0
1221
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
1233
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 node. Now, on a page, drag out any built in control, such as a label. Style/Skin it. The control will take the style of the theme at both runtime and in the designer. Cool! Now, create a custom server control (inherits from WebControl)....
1
1284
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 bring attention. I would like to use these settings, but I am currently restricted to a single theme (more specifically, one color scheme), because you must specify the start and stop color in JS. If I could "theme" JS files, then I could create a...
2
1765
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 it to assume the current System font (that obviously it isn't MS San Sarif) and the current System font Size
4
4242
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 theme (blue title). There are a lot of web sites I have seen that have very attractive themes. I am not a programmer and do not like to edit the php files or css files etc. My preference is to visually create the theme (font,images,background...
1
2364
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 folder that is stored at the root of my project folder. It is really the one I want to use for all pages, so I thought I would reference it in the web.config file: <pages masterPageFile="~/Masters/SiteTemplate.master"
8
5211
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)... I recently put the following script online: <script type="text/javascript"><!-- function playmedia(mediafile) { newwindow=window.open(); if (window.focus) {newwindow.focus()} newwindow.document.write('<html>');
0
8889
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9179
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9116
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.