温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:MyWebPages51aspx汉化最终版
当前文件:
MyWebPagesStarterKit/Administration/WebSite.aspx.cs,打开代码结构图
MyWebPagesStarterKit/Administration/WebSite.aspx.cs,打开代码结构图1//=============================================================================================== 2
// 3
// (c) Copyright Microsoft Corporation. 4
// This source is subject to the Microsoft Permissive License. 5
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx. 6
// All other rights reserved. 7
// 8
//=============================================================================================== 9
10
using System; 11
using System.Web.Security; 12
using System.Web.UI.WebControls; 13
using System.IO; 14
using MyWebPagesStarterKit.Controls; 15
using System.Collections.Generic; 16
using System.Web; 17
using MyWebPagesStarterKit; 18
using System.Web.UI.HtmlControls; 19
20
public partial class Administration_WebSite : PageBaseClass 21
{ 22
protected string lang; 23
//该源码下载自www.51aspx.com(51aspx.com) 24
protected void Page_Load(object sender, EventArgs e) 25
{ 26
//define language for the documentation path 27
lang = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName; 28
if (!File.Exists(HttpContext.Current.Server.MapPath(string.Format("~/Documentation/" + lang + "/quick_guide.html")))) 29
{ 30
lang = "en"; 31
} 32
//5_1_a_s_p_x.c_o_m 33
if (!IsPostBack) 34
{ 35
txtWebSiteTitle.Text = _website.WebSiteTitle; 36
37
List<ThemeEntry> availableThemes = new List<ThemeEntry>(); 38
foreach (string dir in Directory.GetDirectories(Server.MapPath("~/App_Themes"))) 39
{ 40
ThemeEntry entry = new ThemeEntry(); 41
entry.Name = Path.GetFileName(dir); 42
entry.Thumbnail = "~/Images/thumbnail_notavailable.jpg"; 43
44
if (File.Exists(dir + "/thumbnail.jpg")) 45
{ 46
entry.Thumbnail = string.Format("~/App_Themes/{0}/thumbnail.jpg", entry.Name); 47
} 48
availableThemes.Add(entry); 49
} 50
ViewState["Themes"] = availableThemes; 51
52
txtSmtpServer.Text = _website.SmtpServer; 53
txtSmtpUser.Text = _website.SmtpUser; 54
txtSmtpPassword.Text = _website.SmtpPassword; 55
txtSmtpDomain.Text = _website.SmtpDomain; 56
txtFooter.Text = _website.FooterText; 57
txtDescription.Text = _website.Description; 58
txtKeywords.Text = _website.Keywords; 59
txtSenderMail.Text = _website.MailSenderAddress; 60
chkSectionRss.Checked = (_website.EnableSectionRss); 61
} 62
63
btnReset.OnClientClick = string.Format("return confirm('{0}')", ((string)GetGlobalResourceObject("StringsRes", "adm_Website_Reset_Confirmation")).Replace("'", "''")); 64
} 65
66
protected void Page_PreRender(object sender, EventArgs e) 67
{ 68
lstThemes.DataSource = (List<ThemeEntry>)ViewState["Themes"]; 69
lstThemes.DataBind(); 70
71
if (_website.Theme == "Arabic") 72
{ 73
HtmlGenericControl body = (HtmlGenericControl)Master.FindControl("body1"); 74
body.Attributes.Add("dir", "rtl"); 75
} 76
} 77
78
protected void lstThemes_ItemCommand(object source, DataListCommandEventArgs e) 79
{ 80
_website.Theme = (string)lstThemes.DataKeys[e.Item.ItemIndex]; 81
_website.SaveData(); 82
Server.Transfer(Request.RawUrl); 83
} 84
85
protected void btnReset_Click(object sender, EventArgs e) 86
{ 87
_website.ResetWebSite(); 88
FormsAuthentication.SignOut(); 89
Response.Redirect(string.Format("~/Default.aspx?pg={0}", MyWebPagesStarterKit.WebSite.GetInstance().HomepageId), true); 90
} 91
92
protected void btnSave_Click(object sender, EventArgs e) 93
{ 94
_website.WebSiteTitle = txtWebSiteTitle.Text.Trim(); 95
_website.SmtpServer = txtSmtpServer.Text.Trim(); 96
_website.SmtpUser = txtSmtpUser.Text.Trim(); 97
_website.SmtpPassword = txtSmtpPassword.Text.Trim(); 98
_website.SmtpDomain = txtSmtpDomain.Text.Trim(); 99
_website.MailSenderAddress = txtSenderMail.Text.Trim(); 100
_website.FooterText = txtFooter.Text.Trim(); 101
_website.LocaleID = cmbLanguage.SelectedValue; 102
_website.Keywords = txtKeywords.Text.Trim(); 103
_website.Description = txtDescription.Text.Trim(); 104
_website.EnableSectionRss = (chkSectionRss.Checked); 105
_website.SaveData(); 106
107
SitemapEditor editor = new SitemapEditor(); 108
editor.UpdateAdministrationTitles(System.Globalization.CultureInfo.CreateSpecificCulture(cmbLanguage.SelectedValue)); 109
editor.Save(); 110
111
Response.Redirect(Request.RawUrl); 112
} 113
114
[Serializable] 115
public struct ThemeEntry 116
{ 117
private string _name; 118
private string _thumbnail; 119
120
public string Name 121
{ 122
get { return _name; } 123
set { _name = value; } 124
} 125
126
public string Thumbnail 127
{ 128
get { return _thumbnail; } 129
set { _thumbnail = value; } 130
} 131
} 132
} 133





}
}