?? sectionappearance.ascx.cs
字號:
namespace ASPNET.StarterKit.Communities.Admin.EditSections
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
/// <summary>
/// Summary description for SectionAppearance.
/// </summary>
///
public abstract class SectionAppearance : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.DropDownList dropThemes;
protected System.Web.UI.WebControls.DropDownList dropStyles;
protected System.Web.UI.WebControls.Image imgLogoPreview;
protected ASPNET.StarterKit.Communities.HtmlTextBox txtPageHeader;
protected ASPNET.StarterKit.Communities.HtmlTextBox txtPageFooter;
protected System.Web.UI.WebControls.TextBox txtFooter;
protected ASPNET.StarterKit.Communities.LengthValidator LengthValidator1;
protected System.Web.UI.WebControls.TextBox txtPageMetaDesc;
protected ASPNET.StarterKit.Communities.LengthValidator LengthValidator2;
protected System.Web.UI.WebControls.TextBox txtPageMetaKeys;
protected System.Web.UI.WebControls.RadioButton rdlInheritTransformations;
protected System.Web.UI.WebControls.RadioButton rdlSpecifyTransformations;
protected System.Web.UI.WebControls.Panel pnlTransformations;
protected System.Web.UI.WebControls.TextBox txtTransformations;
protected System.Web.UI.WebControls.DropDownList dropFailTheme;
protected System.Web.UI.WebControls.Panel pnlFailTheme;
protected System.Web.UI.WebControls.CustomValidator cvFileName;
protected System.Web.UI.HtmlControls.HtmlInputFile txtLogo;
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.cvFileName.ServerValidate += new System.Web.UI.WebControls.ServerValidateEventHandler(this.cvFileName_ServerValidate);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public SectionInfo Section;
public string PageSkin {
get { return dropThemes.SelectedItem.Value; }
}
public string FailSkin
{
get
{
return dropFailTheme.SelectedItem.Value;
}
}
public string PageStyle {
get { return dropStyles.SelectedItem.Value; }
}
public HttpPostedFile Logo {
get { return txtLogo.PostedFile; }
}
public string PageHeader {
get { return txtPageHeader.Text; }
}
public string PageFooter {
get { return txtPageFooter.Text; }
}
public string Footer {
get { return txtFooter.Text; }
}
public string PageMetaDesc {
get { return txtPageMetaDesc.Text; }
}
public string PageMetaKeys {
get { return txtPageMetaKeys.Text; }
}
public bool InheritTransformations {
get {
if (Section != null && Section.ParentSectionID == -1)
return false;
else
return rdlInheritTransformations.Checked;
}
}
public string Transformations {
get { return txtTransformations.Text; }
}
void Page_Load(object sender, System.EventArgs e) {
if (!IsPostBack) {
// Initialize Themes
dropThemes.DataSource = ThemeUtility.GetThemes();
dropThemes.DataTextField = "ThemeName";
dropThemes.DataValueField = "ThemePath";
dropThemes.DataBind();
dropFailTheme.DataSource = ThemeUtility.GetThemes();
dropFailTheme.DataTextField = "ThemeName";
dropFailTheme.DataValueField = "ThemePath";
dropFailTheme.DataBind();
// Initialize Styles
dropStyles.DataSource = ThemeUtility.GetStyles();
dropStyles.DataTextField = "StyleName";
dropStyles.DataValueField = "StylePath";
dropStyles.DataBind();
if (Section != null) {
// Initialize values from SectionInfo
txtPageHeader.Text = Section.PageHeader;
txtPageFooter.Text = Section.PageFooter;
txtFooter.Text = Section.Footer;
txtPageMetaDesc.Text = Section.PageMetaDesc;
txtPageMetaKeys.Text = Section.PageMetaKeys;
// Initialize Log Preview
if (Section.Logo != String.Empty)
imgLogoPreview.ImageUrl = ResolveUrl("~/" + Section.Logo);
else
imgLogoPreview.Visible = false;
// Initialize transformations
if (Section.ParentSectionID == -1) {
pnlTransformations.Visible = false;
} else {
rdlInheritTransformations.Checked = Section.InheritTransformations;
rdlSpecifyTransformations.Checked = !Section.InheritTransformations;
}
txtTransformations.Text = Section.Transformations;
// if not home section, add inherit option
if (Section.ParentSectionID != -1)
{
dropThemes.Items.Insert(0, new ListItem("Inherit", String.Empty));
dropFailTheme.Items.Insert(0, new ListItem("Inherit", String.Empty));
}
// select default theme
dropThemes.SelectedIndex = -1;
foreach (ListItem item in dropThemes.Items)
if (item.Value == Section.Skin)
item.Selected = true;
// select Fail Over theme
dropFailTheme.SelectedIndex = -1;
foreach (ListItem item in dropFailTheme.Items)
if (item.Value == Section.FailOverSkin)
item.Selected = true;
// select default style
dropStyles.SelectedIndex = -1;
foreach (ListItem item in dropStyles.Items)
if (item.Value == Section.Style)
item.Selected = true;
// if not home section, add inherit option
if (Section.ParentSectionID != -1)
dropStyles.Items.Insert(0, new ListItem("Inherit", String.Empty));
}
else
{
// add inherit option to themes and styles
dropThemes.Items.Insert(0, new ListItem("Inherit", String.Empty));
dropStyles.Items.Insert(0, new ListItem("Inherit", String.Empty));
dropFailTheme.Items.Insert(0, new ListItem("Inherit", String.Empty));
// hide image logo preview
imgLogoPreview.Visible = false;
}
}
}
private void cvFileName_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
{
String FileName = txtLogo.Value;
// Remove path
FileName = FileName.Remove( 0, FileName.LastIndexOf( "\\" ) + 1);
FileName = FileName.Substring(0,FileName.LastIndexOf( "." ));
if(CommunityGlobals.IsNumeric(FileName))
{
args.IsValid = false;
return;
}
args.IsValid = true;
return;
}
private void Page_Load()
{
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -