在服务器上动态更改* .css ??? [英] Change *.css on the fly at the server???

查看:80
本文介绍了在服务器上动态更改* .css ???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我看来,我应该可以做类似的事情:


.... runat =" server"从white.css变为black.css ...


当然如果我能找到怎么样,我就不会打扰你了。

这样的事情是可能的,这样我就可以让用户选择他们喜欢的

配色方案了吗?


然后回帖后新计划会有效。

谢谢

解决方案

" _Who" < Ca ********** @ roadrunner.comwrote in message

news:eq ************** @ TK2MSFTNGP03.phx.gbl ...


当然如果我能找到怎样的话,我就不会打扰你了。


这样的事情是可能的,这样我就可以让用户选择他们喜欢的

配色方案了吗?



1)提供一个样式表列表供用户选择,也许在一个

DropDownList


2)在会话变量中存储所选样式表的路径


3)将所选样式表动态添加到每页的标题中


HtmlLink objCSS = new HtmlLink();

objCSS.Attributes.Add(" href",Session [" Stylesheet"]。ToString());

objCSS.Attributes.Add(" rel"," stylesheet");

objCSS.Attributes.Add(" type"," text / css");

Header.Controls.Add(objCSS);


为避免在每个页面上执行此操作,请创建基页模板

并制作所有其他页面都从中继承,或使用MasterPage / content

页面架构。

-

Mark Rae

ASP.NET MVP
http://www.markrae.net


我将你的代码复制到主vb文件,将第一行更改为Dim

语句并测试我硬编码样式表路径和它工作得很好。


我现在需要添加DropDownList或菜单项。

在任何结束会话事件中删除cookie是否有意义

是在会话启动时读取的。


我不知道这有多复杂,但除非你建议不要这样做,

我会读到这些东西。

谢谢


" Mark Rae [MVP]" < ma ** @ markNOSPAMrae.netwrote in message

news:e7 ************** @ TK2MSFTNGP03.phx.gbl ...
< blockquote class =post_quotes>
" _Who" < Ca ********** @ roadrunner.comwrote in message

news:eq ************** @ TK2MSFTNGP03.phx.gbl ...


>当然如果我能找到怎么样,我就不会打扰你了。

是什么的那样可能,让我可以让用户选择他们喜欢的配色方案吗?



1)提供样式表列表供用户选择,也许在
DropDownList

2)在会话变量中存储所选样式表的路径


3)将所选样式表动态添加到每页的标题中


HtmlLink objCSS = new HtmlLink();

objCSS.Attributes.Add(" href",Session [" Stylesheet"]。ToString());

objCSS.Attributes.Add(" rel"," stylesheet");

objCSS.Attributes.Add(" type"," text / css");

Header.Controls.Add(objCSS);


为避免在每个页面上执行此操作,请创建一个基页

模板并制作所有其他页面都继承自它,或者使用MasterPage /

内容页面架构。


-

Mark Rae

ASP.NET MVP
http://www.markrae.net




" Mark Rae [MVP]" < ma ** @ markNOSPAMrae.netwrote in message

news:e7 ************** @ TK2MSFTNGP03.phx.gbl ...
< blockquote class =post_quotes>
" _Who" < Ca ********** @ roadrunner.comwrote in message

news:eq ************** @ TK2MSFTNGP03.phx.gbl ...


>当然如果我能找到怎么样,我就不会打扰你了。

是什么的那样可能,让我可以让用户选择他们喜欢的配色方案吗?



1)提供一个样式表列表供用户选择,也许在一个

DropDownList



以为我会用菜单。改变了web.sitemap并意识到我甚至不知道如何查找:如何指定siteMapNode执行的URL

somthing on the页面显示。


我发现的所有说明都希望网址指向新页面。


SiteMapNode类没有''似乎有任何属性或事件

允许这样做。


菜单在主菜单中,因此它显示在所有页面中。


需要为url指定:不要更改页面,而是转到这个

页面中的某个位置(实际来自master的代码)并设置会话变量。


并强制回帖?


如果用户点击菜单项来改变颜色我不认为他会喜欢

要更改的页面。


我正在计划的可能。


感谢您提供其他帮助


>

2)在会话变量中存储所选样式表的路径


3)将所选样式表动态添加到每页的标题中


HtmlLink objCSS = new HtmlLink();

objCSS.Attributes.Add(" href",Session [" Stylesheet"]。ToString());

objCSS.Attributes。添加(" rel"," stylesheet");

objCSS.Attributes.Add(" type"," text / css");

标题。 Controls.Add(objCSS);


为避免在每个页面上执行此操作,请创建一个基页

模板并使所有其他页面继承自它,或使用MasterPage /

内容页面架构。


-

Mark Rae

ASP.NET MVP
http://www.markrae.net



Seems to me that I should be able to do something like:

....runat="server" change from white.css to black.css...

Of course if I could have found out how, I wouldn''t be bothering you.

Is something like that possible, so that I can let the users select the
color scheme they like?

Then after post back the new scheme would be effective.
Thanks

解决方案

"_Who" <Ca**********@roadrunner.comwrote in message
news:eq**************@TK2MSFTNGP03.phx.gbl...

Of course if I could have found out how, I wouldn''t be bothering you.

Is something like that possible, so that I can let the users select the
color scheme they like?

1) Provide a list of stylesheets for the user to choose, maybe in a
DropDownList

2) Store the path to the chosen stylesheet in a session variable

3) Add the chosen stylesheet dynamically to the header of each page

HtmlLink objCSS = new HtmlLink();
objCSS.Attributes.Add("href", Session["Stylesheet"].ToString());
objCSS.Attributes.Add("rel", "stylesheet");
objCSS.Attributes.Add("type", "text/css");
Header.Controls.Add(objCSS);

To avoid having to do this on each page, either create a base page template
and make all other pages inherit from it, or use a MasterPage / content
pages architecture.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


I copied your code to a master vb file, changed the first line to a Dim
statement and to test I hard coded a style sheet path and it worked great.

I need to add a DropDownList or menu item now.
Would it make sense to drop a cookie in whatever the closing session event
is and read it in the session startup.

I don''t know how complicated that is but unless you recommend against that,
I''ll read up on such things.
Thanks


"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:e7**************@TK2MSFTNGP03.phx.gbl...

"_Who" <Ca**********@roadrunner.comwrote in message
news:eq**************@TK2MSFTNGP03.phx.gbl...

>Of course if I could have found out how, I wouldn''t be bothering you.

Is something like that possible, so that I can let the users select the
color scheme they like?


1) Provide a list of stylesheets for the user to choose, maybe in a
DropDownList

2) Store the path to the chosen stylesheet in a session variable

3) Add the chosen stylesheet dynamically to the header of each page

HtmlLink objCSS = new HtmlLink();
objCSS.Attributes.Add("href", Session["Stylesheet"].ToString());
objCSS.Attributes.Add("rel", "stylesheet");
objCSS.Attributes.Add("type", "text/css");
Header.Controls.Add(objCSS);

To avoid having to do this on each page, either create a base page
template and make all other pages inherit from it, or use a MasterPage /
content pages architecture.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net




"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:e7**************@TK2MSFTNGP03.phx.gbl...

"_Who" <Ca**********@roadrunner.comwrote in message
news:eq**************@TK2MSFTNGP03.phx.gbl...

>Of course if I could have found out how, I wouldn''t be bothering you.

Is something like that possible, so that I can let the users select the
color scheme they like?


1) Provide a list of stylesheets for the user to choose, maybe in a
DropDownList

Thought I''d use a menu. Changed the web.sitemap and realized I don''t even
know how to look up: "how to specify the url for the siteMapNode to execute
somthing on the page showing".

All the instructions I found expects that the url will point to a new page.

The SiteMapNode Class doesn''t appear to have any properties nor events that
allow that.

The menu is in the master so it shows in all the pages.

Need to specify for the url: do not change pages but go to someplace in this
page (code actually from the master) and set a session variable.

And force a post back?

If the user clicked a menu item to change the colors I don''t think he''d like
the page to change.

Is what I''m planning possible.

Thanks for the other help

>
2) Store the path to the chosen stylesheet in a session variable

3) Add the chosen stylesheet dynamically to the header of each page

HtmlLink objCSS = new HtmlLink();
objCSS.Attributes.Add("href", Session["Stylesheet"].ToString());
objCSS.Attributes.Add("rel", "stylesheet");
objCSS.Attributes.Add("type", "text/css");
Header.Controls.Add(objCSS);

To avoid having to do this on each page, either create a base page
template and make all other pages inherit from it, or use a MasterPage /
content pages architecture.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net



这篇关于在服务器上动态更改* .css ???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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