|
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class AuthMaster : System.Web.UI.MasterPage
{
public string TableWidth = "";
protected void Page_Load(object sender, EventArgs e)
{
//default to SiteID="1"
string SiteID = Request.QueryString["SiteID"] == null ? "1" : Request.QueryString["SiteID"].ToString();
SiteInfo MySiteInfo = new SiteInfo();
//use Session["SiteInfo"] to reduce database traffic.
//This is userful since many pages at the web site uses the same master page.
try
{
if (Session["SiteInfo"] == null)
{
MySiteInfo.SiteID = int.Parse(SiteID);
MySiteInfo.RetrieveSiteInfo();
Session["SiteInfo"] = MySiteInfo;
}
else
{
MySiteInfo = (SiteInfo)Session["SiteInfo"];
//check to see if SiteID in session is the same as the current. If changed, retrieve new site info
if (MySiteInfo.SiteID != int.Parse(SiteID))
{
MySiteInfo.SiteID = int.Parse(SiteID);
MySiteInfo.RetrieveSiteInfo();
Session["SiteInfo"] = MySiteInfo;
}
}
ApplySiteStyle(MySiteInfo);
}
catch (Exception ex)
{
lblMasterPageError.Text=ex.Message.ToString();
}
}
private void ApplySiteStyle(SiteInfo siteInfo)
{
MainStyle.Href = siteInfo.StyleSheetName;
imgHeader.ImageUrl = siteInfo.HeaderImagePath;
imgHeader.Width = Unit.Pixel((int)siteInfo.HeaderWidth);
imgHeader.Height = Unit.Pixel((int)siteInfo.HeaderHeight);
lblHeaderText.Text = siteInfo.HeaderText;
TableWidth = (imgHeader.Width == 0 ? "800" : imgHeader.Width.ToString());
DataBind();
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Web & Database Developer. Design and implement web and database applications utilizing Microsoft and other development tools.