internal MainTagNameToTypeMapper(BaseTemplateParser parser) { this._parser = parser; if (parser != null) { PagesSection pagesConfig = parser.PagesConfig; if (pagesConfig != null) { this._tagNamespaceRegisterEntries = pagesConfig.TagNamespaceRegisterEntriesInternal; if (this._tagNamespaceRegisterEntries != null) { this._tagNamespaceRegisterEntries = (TagNamespaceRegisterEntryTable)this._tagNamespaceRegisterEntries.Clone(); } this._userControlRegisterEntries = pagesConfig.UserControlRegisterEntriesInternal; if (this._userControlRegisterEntries != null) { this._userControlRegisterEntries = (Hashtable)this._userControlRegisterEntries.Clone(); } } if (parser.FInDesigner && (this._tagNamespaceRegisterEntries == null)) { this._tagNamespaceRegisterEntries = new TagNamespaceRegisterEntryTable(); foreach (TagNamespaceRegisterEntry entry in PagesSection.DefaultTagNamespaceRegisterEntries) { this._tagNamespaceRegisterEntries[entry.TagPrefix] = new ArrayList(new object[] { entry }); } } } }
protected void btnSubmit_OnClick(object sender, EventArgs e) { Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~/"); PagesSection pagesSection = (PagesSection)configuration.GetSection("system.web/pages"); BusiBlocks.Notification.BusiBlocksSmtpNotificationProvider bb = new BusiBlocks.Notification.BusiBlocksSmtpNotificationProvider(); FeedbackForm form = new FeedbackForm() { Type = ddlFeedbackType.SelectedValue, Subject = txtSubject.Text, Comments = txtComments.Text, Theme = pagesSection.Theme.ToString(), Browser = Request.Browser.Type, Page = this.Page.ToString(), Time = DateTime.Now, UserId = Page.User.Identity.Name }; bb.SendMail(CreateMessageFromTemplate(form)); FeedbackFormManager.CreateFeedbackFormRequest(form); ClearFields(); }
void ProcessAdd(string val, PagesSection section, SettingsMappingWhatContents how) { if (val == "controls") { AddControl(section, how); } }
protected void ddlTheme_SelectedIndexChanged(object sender, EventArgs e) { Configuration config = WebConfigurationManager.OpenWebConfiguration("~/"); PagesSection pages = (PagesSection)config.GetSection("system.web/pages"); pages.Theme = ddlTheme.SelectedItem.Text.ToString(); if (!pages.SectionInformation.IsLocked) { config.Save(); Response.Redirect("dashboard.aspx"); } else { Response.Write("<script>alert('Could not save configuration')</script>"); } using (var db = new LogUserDataContext()) { LogUser lu = new LogUser() { Theme = pages.Theme.ToString(), Language = DropDownList1.SelectedValue.ToString() }; db.SubmitChanges(); } }
internal override void LoadConfigDefaults() { base.LoadConfigDefaults(); #if NET_2_0 PagesSection ps = PagesConfig; #else PagesConfiguration ps = PagesConfig; #endif notBuffer = !ps.Buffer; enableSessionState = ps.EnableSessionState; enableViewStateMac = ps.EnableViewStateMac; smartNavigation = ps.SmartNavigation; validateRequest = ps.ValidateRequest; #if NET_2_0 masterPage = ps.MasterPageFile; if (masterPage.Length == 0) { masterPage = null; } enable_event_validation = ps.EnableEventValidation; maxPageStateFieldLength = ps.MaxPageStateFieldLength; theme = ps.Theme; if (theme.Length == 0) { theme = null; } styleSheetTheme = ps.StyleSheetTheme; if (styleSheetTheme.Length == 0) { styleSheetTheme = null; } maintainScrollPositionOnPostBack = ps.MaintainScrollPositionOnPostBack; #endif }
protected void Page_Load(object sender, EventArgs e) { Session["lang"] = DropDownList15.SelectedItem.Value; if (!IsPostBack) { DropDownList2.Items[0].Value = "1"; DropDownList2.Items[1].Value = "0"; //Your ddl initialization here Configuration config = WebConfigurationManager.OpenWebConfiguration("~/"); //Get the required section of the web.config file by using configuration object. PagesSection pages = (PagesSection)config.GetSection("system.web/pages"); if (Session["selectDrpDwn2"] != null) { DropDownList2.SelectedIndex = (int)(Session["selectDrpDwn2"]); } // Label5.Text = Session["selectDrpDwn"].ToString(); String p = pages.Theme.ToString(); if (p == "Theme2") { DropDownList2.SelectedIndex = 1; } else if (p == "Theme1") { DropDownList2.SelectedIndex = 0; } else { DropDownList2.SelectedIndex = 2; } } }
internal override void LoadConfigDefaults () { base.LoadConfigDefaults (); #if NET_2_0 PagesSection ps = PagesConfig; #else PagesConfiguration ps = PagesConfig; #endif notBuffer = !ps.Buffer; enableSessionState = ps.EnableSessionState; enableViewStateMac = ps.EnableViewStateMac; smartNavigation = ps.SmartNavigation; validateRequest = ps.ValidateRequest; #if NET_2_0 string value = ps.MasterPageFile; if (value.Length > 0) masterPage = new MainDirectiveAttribute <string> (value, true); enable_event_validation = ps.EnableEventValidation; maxPageStateFieldLength = ps.MaxPageStateFieldLength; value = ps.Theme; if (value.Length > 0) theme = new MainDirectiveAttribute <string> (value, true); styleSheetTheme = ps.StyleSheetTheme; if (styleSheetTheme.Length == 0) styleSheetTheme = null; maintainScrollPositionOnPostBack = ps.MaintainScrollPositionOnPostBack; #endif }
void AddNamespaces(Dictionary <string, bool> imports) { if (BuildManager.HaveResources) { imports.Add("System.Resources", true); } PagesSection pages = PagesConfig; if (pages == null) { return; } NamespaceCollection namespaces = pages.Namespaces; if (namespaces == null || namespaces.Count == 0) { return; } foreach (NamespaceInfo nsi in namespaces) { string ns = nsi.Namespace; if (imports.ContainsKey(ns)) { continue; } imports.Add(ns, true); } }
protected override void ComputeHashCode(HashCodeCombiner hashCodeCombiner) { base.ComputeHashCode(hashCodeCombiner); PagesSection pagesConfig = MTConfigUtil.GetPagesConfig(base.VirtualPath); hashCodeCombiner.AddObject(Util.GetRecompilationHash(pagesConfig)); }
internal override void LoadConfigDefaults() { base.LoadConfigDefaults(); PagesSection ps = PagesConfig; autoEventWireup = ps.AutoEventWireup; enableViewState = ps.EnableViewState; compilationMode = ps.CompilationMode; }
protected override void OnPreInit(EventArgs e) { PagesSection ps = (PagesSection)ConfigurationManager.GetSection("system.web/pages"); if (!String.IsNullOrEmpty(ps.Theme)) { Theme = ps.Theme; } base.OnPreInit(e); }
public static string GetThemeFromWebConfig() { PagesSection section = (PagesSection)WebConfigurationManager.GetSection("system.web/pages", "~"); if (section != null) { return(section.Theme); } return(string.Empty); }
internal static PageParserFilter Create(PagesSection pagesConfig, System.Web.VirtualPath virtualPath, TemplateParser parser) { PageParserFilter filter = pagesConfig.CreateControlTypeFilter(); if (filter != null) { filter.InitializeInternal(virtualPath, parser); } return(filter); }
void ProcessClear(string val, PagesSection section, SettingsMappingWhatContents how) { if (val == "controls") { section.Controls.Clear(); } else if (val == "tagMapping") { section.TagMapping.Clear(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Configuration config = WebConfigurationManager.OpenWebConfiguration("~/"); PagesSection pages = (PagesSection)config.GetSection("system.web/pages"); DropDownList1.SelectedValue = DropDownList1.Items.FindByText(pages.Theme).Value; } }
static WebConfig() { if (RunTimeEnvironment.IsAspnetApp) { PagesSection pagesSection = ConfigurationManager.GetSection("system.web/pages") as PagesSection; if (pagesSection != null) { ValidateRequest = pagesSection.ValidateRequest; } } }
public void Run() { PagesSection c = (PagesSection)System.Web.Configuration.WebConfigurationManager.GetSection("system.web/pages"); if (c == null) { Console.WriteLine("null"); } else { Console.WriteLine(c.StyleSheetTheme); } }
void RegisterConfigControls() { PagesSection pages = WebConfigurationManager.GetSection("system.web/pages") as PagesSection; if (pages == null) { return; } TagPrefixCollection controls = pages.Controls; if (controls == null || controls.Count == 0) { return; } IList appCode = BuildManager.CodeAssemblies; bool haveCodeAssemblies = appCode != null && appCode.Count > 0; Assembly asm; foreach (TagPrefixInfo tpi in controls) { if (!String.IsNullOrEmpty(tpi.TagName)) { RegisterFoundry(tpi.TagPrefix, tpi.TagName, tpi.Source, true); } else if (String.IsNullOrEmpty(tpi.Assembly)) { if (haveCodeAssemblies) { foreach (object o in appCode) { asm = o as Assembly; if (asm == null) { continue; } RegisterFoundry(tpi.TagPrefix, asm, tpi.Namespace, true); } } } else if (!String.IsNullOrEmpty(tpi.Namespace)) { RegisterAssemblyFoundry(tpi.TagPrefix, tpi.Assembly, tpi.Namespace, true); } } }
// The code is copied from NDP\fx\src\xsp\system\web\compilation\assemblybuilder.cs private static void AddVBGlobalNamespaceImports(CompilerParameters compilParams) { // Put together the VB import string on demand if (VBImportsString == null) { // Get the Web application configuration. PagesSection pagesConfig = (PagesSection)WebConfigurationManager.GetSection("system.web/pages"); if (pagesConfig.Namespaces == null) { VBImportsString = String.Empty; } else { StringBuilder sb = new StringBuilder(); sb.Append("/imports:"); bool nextItemNeedsComma = false; // Auto-import Microsoft.VisualBasic is needed if (pagesConfig.Namespaces.AutoImportVBNamespace) { sb.Append("Microsoft.VisualBasic"); nextItemNeedsComma = true; } // Add all the namespaces from the config <namespaces> section foreach (NamespaceInfo entry in pagesConfig.Namespaces) { // If there was a previous entry, we need a comma separator if (nextItemNeedsComma) { sb.Append(','); } sb.Append(entry.Namespace); nextItemNeedsComma = true; } VBImportsString = sb.ToString(); } } // Prepend it to the compilerOptions if (VBImportsString.Length > 0) { CompilationUtil.PrependCompilerOption(compilParams, VBImportsString); } }
// TODO: remove the dependency on ConfigurationManager and write a test public void Process(SourceFile file) { PagesSection section = ConfigurationManager.GetSection("system.web/pages") as PagesSection; if (section == null) { return; } foreach (NamespaceInfo ni in section.Namespaces) { if (ni.Namespace.StartsWith("System.Web")) { continue; } file.Imports.Add(ni.Namespace); } }
static WebConfig() { CompilationSection compilationSection = ConfigurationManager.GetSection("system.web/compilation") as CompilationSection; if (compilationSection != null) { IsDebugMode = compilationSection.Debug; } PagesSection pagesSection = ConfigurationManager.GetSection("system.web/pages") as PagesSection; if (pagesSection != null) { ValidateRequest = pagesSection.ValidateRequest; } }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { Configuration config = WebConfigurationManager.OpenWebConfiguration("~/"); PagesSection pages = (PagesSection)config.GetSection("system.web/pages"); pages.Theme = DropDownList1.SelectedItem.Text.ToString(); if (!pages.SectionInformation.IsLocked) { config.Save(); Response.Redirect(Request.RawUrl); } else { Response.Write("<script>alert('Could not save configuration')</script>"); } }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { Configuration config = WebConfigurationManager.OpenWebConfiguration("~/"); //Get the required section of the web.config file by using configuration object. PagesSection pages = (PagesSection)config.GetSection("system.web/pages"); //Update the new values. pages.Theme = DropDownList1.SelectedItem.Text.ToString(); //save the changes by using Save() method of configuration object. if (!pages.SectionInformation.IsLocked) { config.Save(); Response.Redirect("Default.aspx"); } else { Response.Write("<script>alert('Could not save configuration')</script>"); } }
private static void AddVBGlobalNamespaceImports(CompilerParameters compilParams) { if (s_vbImportsString == null) { PagesSection pagesAppConfig = MTConfigUtil.GetPagesAppConfig(); if (pagesAppConfig.Namespaces == null) { s_vbImportsString = string.Empty; } else { StringBuilder builder = new StringBuilder(); builder.Append("/imports:"); bool flag = false; if (pagesAppConfig.Namespaces.AutoImportVBNamespace) { builder.Append("Microsoft.VisualBasic"); flag = true; } foreach (NamespaceInfo info in pagesAppConfig.Namespaces) { if (flag) { builder.Append(','); } builder.Append(info.Namespace); flag = true; } s_vbImportsString = builder.ToString(); } } if (s_vbImportsString.Length > 0) { if (compilParams.CompilerOptions == null) { compilParams.CompilerOptions = s_vbImportsString; } else { compilParams.CompilerOptions = s_vbImportsString + " " + compilParams.CompilerOptions; } } }
public object MapSection(object section, List <SettingsMappingWhat> whats) { if (!(section is PagesSection)) { return(section); } PagesSection pageConfig = section as PagesSection; if (pageConfig == null) { return(section); } List <SettingsMappingWhatContents> contents; string val; foreach (SettingsMappingWhat what in whats) { contents = what.Contents; if (contents == null || contents.Count == 0) { continue; } val = what.Value; foreach (SettingsMappingWhatContents item in contents) { switch (item.Operation) { case SettingsMappingWhatOperation.Add: ProcessAdd(val, pageConfig, item); break; case SettingsMappingWhatOperation.Clear: ProcessClear(val, pageConfig, item); break; } } } return(pageConfig); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Configuration config = WebConfigurationManager.OpenWebConfiguration("~/"); PagesSection pages = (PagesSection)config.GetSection("system.web/pages"); ddlTheme.SelectedValue = ddlTheme.Items.FindByText(pages.Theme).Value; } if (Session["id"] != null) { LblName.Text = Session["id"].ToString(); } else { Session.RemoveAll(); } }
public static object GetEvalData(string expression) { string result = String.Empty; // Get the Web application configuration. Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~"); // Get the 'pages' section. PagesSection pagesSection = (PagesSection)configuration.GetSection("system.web/pages"); bool hasArgs = System.Text.RegularExpressions.Regex.IsMatch(expression, ".+\\(.+\\)", RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled | RegexOptions.IgnoreCase); //Determine the expression result if (expression.ToLowerInvariant().StartsWith(STYLESHEET_THEME)) { if (hasArgs) { expression = expression.Substring(STYLESHEET_THEME.Length + 1, expression.Length - STYLESHEET_THEME.Length - 2); System.Web.UI.Control helper = new Control(); result = helper.ResolveUrl(String.Format(expression, pagesSection.StyleSheetTheme)); } else { result = pagesSection.StyleSheetTheme; } } else if (expression.ToLowerInvariant().StartsWith(THEME)) { if (hasArgs) { expression = expression.Substring(THEME.Length + 1, expression.Length - THEME.Length - 2); System.Web.UI.Control helper = new Control(); result = helper.ResolveUrl(String.Format(expression, pagesSection.Theme)); } else { result = pagesSection.Theme; } } return(result); }
static WebConfig() { IsAspnetApp = string.IsNullOrEmpty(System.Web.HttpRuntime.AppDomainAppId) == false; CompilationSection compilationSection = ConfigurationManager.GetSection("system.web/compilation") as CompilationSection; if (compilationSection != null) { IsDebugMode = compilationSection.Debug; } PagesSection pagesSection = ConfigurationManager.GetSection("system.web/pages") as PagesSection; if (pagesSection != null) { ValidateRequest = pagesSection.ValidateRequest; } }
internal MainTagNameToTypeMapper(BaseTemplateParser parser) { _parser = parser; if (parser != null) { PagesSection pagesConfig = parser.PagesConfig; if (pagesConfig != null) { // Clone it so we don't modify the config settings _tagNamespaceRegisterEntries = pagesConfig.TagNamespaceRegisterEntriesInternal; if (_tagNamespaceRegisterEntries != null) { _tagNamespaceRegisterEntries = (TagNamespaceRegisterEntryTable)_tagNamespaceRegisterEntries.Clone(); } _userControlRegisterEntries = pagesConfig.UserControlRegisterEntriesInternal; if (_userControlRegisterEntries != null) { _userControlRegisterEntries = (Hashtable)_userControlRegisterEntries.Clone(); } } // if (parser.FInDesigner && (_tagNamespaceRegisterEntries == null)) { _tagNamespaceRegisterEntries = new TagNamespaceRegisterEntryTable(); foreach (TagNamespaceRegisterEntry entry in PagesSection.DefaultTagNamespaceRegisterEntries) { _tagNamespaceRegisterEntries[entry.TagPrefix] = new ArrayList(new object[] { entry }); } } } }
void AddControl(PagesSection section, SettingsMappingWhatContents how) { Dictionary <string, string> attrs = how.Attributes; if (attrs == null || attrs.Count == 0) { return; } string tagPrefix, nameSpace, asm, tagName, source; if (!attrs.TryGetValue("tagPrefix", out tagPrefix)) { tagPrefix = String.Empty; } if (!attrs.TryGetValue("namespace", out nameSpace)) { nameSpace = String.Empty; } if (!attrs.TryGetValue("assembly", out asm)) { asm = String.Empty; } if (!attrs.TryGetValue("tagName", out tagName)) { tagName = String.Empty; } if (!attrs.TryGetValue("src", out source)) { source = String.Empty; } TagPrefixInfo info = new TagPrefixInfo(tagPrefix, nameSpace, asm, tagName, source); section.Controls.Add(info); }