Change *.css on the fly at the server???

W

_Who

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
 
W

_Who

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 said:
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.
 
W

_Who

Mark Rae said:
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.
 
W

_Who

Revised ("that" changed to "what I need"
_Who said:
Mark Rae said:
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 what I need.

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.
 
W

_Who

I can't find out how to make a menu-click exercise master code with out
changing the page.

That is, if I add a page url to the menuitem and the item gets clicked user
will see his page change.

A url is the only thing I see on a menuitem to handle a click and that
doesn't appear to be what I need.


All I want to happen is store a new session variable value and run the code
you showed me.

If the menuitem had a click event to the master code behind I would have
used that.

Got any idea about how to do this


Thanks for all the help
 
W

_Who

I'm using much of your time and because I don't know how to ask the right
question I'm not advancing.

Maybe if I tell you what I've done.

I create the menu using web.sitemap containing a sitemap, and in my master
file

<asp:Menu runat="server" ID="MainMenu" Style="Font-Size:16pt; border-style:
ridge; border-color: Maroon;

border-width: 4px" StaticDisplayLevels="2" DataSourceID="SiteMapDataSource1"



web.site contains these (along with other items):

<siteMapNode title="Options" url="d.aspx">

<siteMapNode title="Black Background" url="a.aspx" />

<siteMapNode title="White Background" url="b.aspx" />

<siteMapNode title="Textured Background" url="c.aspx" />

</siteMapNode>



I know about :
Protected Sub MainMenu_MenuItemClick(ByVal sender As Object, ByVal e As
MenuEventArgs)

and that MenuEventArgs has a text property that I can use to identify which
item was clicked.

But I can't get past the requirement that each siteMapNode have a nonblank
url.

What I need to be able todo when the user clickes and item is to have the
page be unchanged, and have the click event raised or have some routine on
the master run.

Like if I could use for the url *.subroutine1
meaning go to subroutine1 on this page.


got any ideas?


THANKS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top