在设计时获取当前主题名称。 [英] Get the current theme name at design time.

查看:91
本文介绍了在设计时获取当前主题名称。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


有没有办法在设计时获得当前的主题名称?


我正在尝试编写一个自定义控件,我需要使用

当前主题中的图像。我已经为页面以及

web.config设置了一个主题。


控件在运行时看起来没问题但在Visual中查看时工作室

设计师无法接收当前主题。


提前致谢,

Greg。

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.

推荐答案

24 mei,11:40," greg" < g ... @ metastorm.no.spam.comwrote:
On 24 mei, 11:40, "greg" <g...@metastorm.no.spam.comwrote:

大家好,


有没有办法在设计时获取当前的主题名称?


我正在尝试编写一个自定义控件,我需要使用来自

当前的图像主题。我已经为页面以及

web.config设置了一个主题。


控件在运行时看起来没问题但在Visual中查看时工作室

设计师无法接收当前主题。


提前致谢,

Greg。
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

Page.Theme


>
>

Page.Theme
Page.Theme



你好Veerle,

Page.Theme在设计时无法使用。


谢谢,

格雷格。

Hi Veerle,

Page.Theme at design time is not available.

Thanks,
Greg.


re :
re:

有没有办法在设计时获得当前的主题名称?
Is there a way to get the current theme name at design time?



您可以通过构建到正确目录的字符串路径来解决这个问题。


您知道所有主题位于App_Themes目录下:

网站

\ App_Themes

\ BlueTheme

Controls.skin

BlueTheme.css

\ PinkTheme

Controls.skin

PinkTheme.css


如果你在查询字符串中设置主题:


受保护的void Page_PreInit(对象发送者,EventArgs e)

{

switch(Request.QueryString [" theme"])

{

case" Blue":

Page.Theme =" ; BlueTheme;

休息;

case粉红色:

Page.Theme =" PinkTheme";

休息;

}

}


....你可以建立一个到你想要的正确目录的路径用于图像。


用于指向direc的相对路径当前主题的保守党:


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


对于当前主题目录的完全限定路径:


string fullappname = Request.Url.Host

string fullpath =" http://" + fullappname + Request.ApplicationPath +" /" + App_Themes +" /" +

Request.QueryString [" theme"])+" /"


请仔细检查语法,因为我通常在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.com在消息新闻中写道:eJ ************** @ TK2MSFTNGP06.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 :
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...


大家好,


有没有办法在设计时获得当前的主题名称?


我'我正在尝试编写一个自定义控件,我需要使用当前主题中的图像。我有

为页面和web.config分配了一个主题。


控件在运行时看起来不错但在Visual中查看时工作室设计师无法接受

当前主题。


提前致谢,

Greg。
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.



这篇关于在设计时获取当前主题名称。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆