Tuesday, 8 October 2013

Changing the SiteMaster StyleSheet from Codebehind

- In the SiteMaster Page, add ID to StyleSheet tag:
     <link id="layoutStyleSheet" href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
- In a login page, set a SESSION to a value. e.g. SESSION["user"] = "test"
- In the SiteMaster Page_Load method:
     protected void Page_Load(object sender, EventArgs e)
     {
         if (Session["user"] != null)
         {
             if (Session["user"].ToString() == "test")
             {
                 HtmlLink link = Page.Master.FindControl("layoutStyleSheet") as HtmlLink;
                 link.Href = "~/Styles/Aqualinc.css";
             }
             .
             .
             .       
         }
     }

SQL: Generate a range of numbers

SELECT ones.n + 10*tens.n + 100*hundreds.n + 1000*thousands.n FROM       (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) ones(n),      (VALU...