PC Review


Reply
Thread Tools Rate Thread

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

 
 
_Who
Guest
Posts: n/a
 
      25th Aug 2008
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


 
Reply With Quote
 
 
 
 
_Who
Guest
Posts: n/a
 
      26th Aug 2008
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]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "_Who" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> 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



 
Reply With Quote
 
_Who
Guest
Posts: n/a
 
      26th Aug 2008

"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "_Who" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> 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



 
Reply With Quote
 
_Who
Guest
Posts: n/a
 
      26th Aug 2008
Revised ("that" changed to "what I need"
"_Who" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>
> "Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> "_Who" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>
>>> 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 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.
>>
>>
>> --
>> Mark Rae
>> ASP.NET MVP
>> http://www.markrae.net

>
>



 
Reply With Quote
 
_Who
Guest
Posts: n/a
 
      26th Aug 2008
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



"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> "_Who" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>
>> 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.

>
>
> Yes, but it will require a round-trip to the server because you can only
> set / retrieve session variables server-side...
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net



 
Reply With Quote
 
_Who
Guest
Posts: n/a
 
      26th Aug 2008
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





"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "_Who" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> If the menuitem had a click event to the master code behind I would have
>> used that.

>
> Set the NavigateUrl property to an empty string.
> http://msdn.microsoft.com/en-us/libr...vigateurl.aspx
>
> Use the Value property
> http://msdn.microsoft.com/en-us/libr...tem.value.aspx
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net



 
Reply With Quote
 
_Who
Guest
Posts: n/a
 
      27th Aug 2008

"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "_Who" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> If the menuitem had a click event to the master code behind I would have
>> used that.


Somehow I kept missing the MenuItemClick event.
Don't know how but I did.

Thanks


>
> Set the NavigateUrl property to an empty string.
> http://msdn.microsoft.com/en-us/libr...vigateurl.aspx
>
> Use the Value property
> http://msdn.microsoft.com/en-us/libr...tem.value.aspx
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do i change this connect string to support a SQL Server 2000 running on port 8832 User ID=car;Password=rat;Server=abc.def.hij;Initial Catalog=foobar i tried Server=abc.def.hij:8823 and Server=abc.def.hij;port=8823 neither of these work Daniel Microsoft Dot NET Framework 1 16th Dec 2004 09:55 PM
Trying to change incoming server(pop3) for Outlook with Small Business Server. =?Utf-8?B?Sm9obg==?= Microsoft Outlook 0 29th Oct 2003 05:16 PM
Q: Is it possible to remove a windows 2000 server that is Primary Domain Controller, and let the old NT 4.0 server change from BDC to PDC again? Freddy Ulvseth Microsoft Windows 2000 Networking 3 29th Aug 2003 04:33 PM
Q: Is it possible to remove a windows 2000 server that is Primary Domain Controller, and let the old NT 4.0 server change from BDC to PDC again? Freddy Ulvseth Microsoft Windows 2000 Active Directory 3 29th Aug 2003 04:33 PM
Q: Is it possible to remove a windows 2000 server that is Primary Domain Controller, and let the old NT 4.0 server change from BDC to PDC again? Freddy Ulvseth Microsoft Windows 2000 3 29th Aug 2003 04:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:47 PM.