protected void Page_Load(object sender, EventArgs e) { try { pageId = Utility.GetIntParameter("pageId"); regionId = Utility.GetIntParameter("regionId"); //TODO: CMC - set page title here this.Title = LocalizationUtility.GetText("titleAddEditRegion"); if(regionId <= 0) { _selectedRegion = new Region(); _selectedRegion.RegionGuid = Guid.NewGuid(); } else { _selectedRegion = new Region(regionId); } if(!Page.IsPostBack) { Content.Page _selectedPage = new Content.Page(pageId); ProviderCollection providerCollection = new ProviderController().FetchAll(); ddlProvider.DataSource = providerCollection; ddlProvider.DataValueField = "ProviderId"; ddlProvider.DataTextField = "Name"; ddlProvider.DataBind(); TemplateRegionCollection templateRegionCollection = new TemplateRegionController().FetchByTemplateId(_selectedPage.TemplateId); ddlTemplateRegion.DataSource = templateRegionCollection; ddlTemplateRegion.DataValueField = "TemplateRegionId"; ddlTemplateRegion.DataTextField = "Name"; ddlTemplateRegion.DataBind(); txtTitle.Text = _selectedRegion.Title; chkShowTitle.Checked = _selectedRegion.ShowTitle; txtSortOrder.Text = _selectedRegion.SortOrder.ToString(); ddlProvider.SelectedValue = _selectedRegion.ProviderId.ToString(); ddlTemplateRegion.SelectedValue = _selectedRegion.TemplateRegionId.ToString(); } } catch(Exception ex) { Logger.Error(typeof(region).Name, ex); Master.MessageCenter.DisplayCriticalMessage(ex.Message); } }
protected override void OnInit(EventArgs e) { pageId = Utility.GetIntParameter("pageId"); if (pageId > 0) { _page = PageCache.GetPageByID(pageId); } else { _page = PageCache.GetDefaultPage(); } if (_page != null) { this._title = _page.Title; htmlMetaKeywords.Attributes.Add("name", "keywords"); htmlMetaKeywords.Attributes.Add("content", _page.Keywords); Page.Header.Controls.Add(htmlMetaKeywords); htmlMetaDescription.Attributes.Add("name", "description"); htmlMetaDescription.Attributes.Add("content", _page.Description); Page.Header.Controls.Add(htmlMetaDescription); Template template = new Template(_page.TemplateId); if (template.TemplateId > 0) { if (!string.IsNullOrEmpty(template.StyleSheet)) { Header.Controls.Add(new LiteralControl("<link ID=\"stylesheet\" rel=\"stylesheet\" type=\"text/css\" href=\"" + Page.ResolveUrl(template.StyleSheet) + "\" />")); } } //now get the template regions for this page TemplateRegionCollection templateRegionCollection = new TemplateRegionController().FetchByTemplateId(_page.TemplateId); //now get the regions for the page RegionCollection regionCollection = new RegionController().FetchRegionsByPageId(_page.PageId); regionCollection.OrderByAsc("SortOrder"); HtmlGenericControl templateRegionControl; HtmlGenericControl regionControl; HtmlGenericControl regionTitleControl; foreach (TemplateRegion templateRegion in templateRegionCollection) { //1st, add the region templateRegionControl = new HtmlGenericControl("div"); templateRegionControl.Attributes.Add("id", templateRegion.Name.Replace(" ", string.Empty).ToString()); ((PlaceHolder)this.Placeholders["contentPlaceHolder"]).Controls.Add(templateRegionControl); //2nd, add the regions that belong in this control foreach (Region _region in regionCollection) { if (_region.TemplateRegionId == templateRegion.TemplateRegionId) //then it belongs in this TemplateRegion { regionControl = new HtmlGenericControl("div"); regionControl.Attributes.Add("class", "contentGroup"); if (_region.ShowTitle) { regionTitleControl = new HtmlGenericControl("div"); regionTitleControl.Attributes.Add("class", "contentGroupHeader"); regionTitleControl.InnerHtml = "<span class=\"contentGroupHeaderText\">" + _region.Title + "</span>"; regionControl.Controls.Add(regionTitleControl); } templateRegionControl.Controls.Add(regionControl); Provider _provider = new Content.Provider(_region.ProviderId); if (!string.IsNullOrEmpty(_provider.StyleSheet)) { Header.Controls.Add(new LiteralControl("<link ID=\"stylesheet\" rel=\"stylesheet\" type=\"text/css\" href=\"" + Page.ResolveUrl(_provider.StyleSheet) + "\" />")); } ProviderControl _providerControl = Page.LoadControl(_provider.ViewControl) as ProviderControl; _providerControl.PageId = _page.PageId; _providerControl.RegionId = _region.RegionId; _providerControl.ProviderId = _provider.ProviderId; regionControl.Controls.Add(_providerControl); } } } } base.OnInit(e); }
protected override void OnInit(EventArgs e) { pageId = Utility.GetIntParameter("pageId"); if (pageId > 0) { _page = PageCache.GetPageByID(pageId); } else { _page = PageCache.GetDefaultPage(); } if (_page != null) { this._title = _page.Title; htmlMetaKeywords.Attributes.Add("name", "keywords"); htmlMetaKeywords.Attributes.Add("content", _page.Keywords); Page.Header.Controls.Add(htmlMetaKeywords); htmlMetaDescription.Attributes.Add("name", "description"); htmlMetaDescription.Attributes.Add("content", _page.Description); Page.Header.Controls.Add(htmlMetaDescription); Template template = new Template(_page.TemplateId); if (template.TemplateId > 0) { if (!string.IsNullOrEmpty(template.StyleSheet)) { Header.Controls.Add(new LiteralControl("<link ID=\"stylesheet\" rel=\"stylesheet\" type=\"text/css\" href=\"" + Page.ResolveUrl(template.StyleSheet) + "\" />")); } } //now get the template regions for this page TemplateRegionCollection templateRegionCollection = new TemplateRegionController().FetchByTemplateId(_page.TemplateId); //now get the regions for the page RegionCollection regionCollection = new RegionController().FetchRegionsByPageId(_page.PageId); regionCollection.OrderByAsc("SortOrder"); HtmlGenericControl templateRegionControl; HtmlGenericControl regionControl; HtmlGenericControl regionTitleControl; foreach (TemplateRegion templateRegion in templateRegionCollection) { //1st, add the region templateRegionControl = new HtmlGenericControl("div"); templateRegionControl.Attributes.Add("id", templateRegion.Name.Replace(" ", string.Empty).ToString()); ((PlaceHolder)this.Placeholders["contentPlaceHolder"]).Controls.Add(templateRegionControl); //2nd, add the regions that belong in this control foreach (Region _region in regionCollection) { if (_region.TemplateRegionId == templateRegion.TemplateRegionId) { //then it belongs in this TemplateRegion regionControl = new HtmlGenericControl("div"); regionControl.Attributes.Add("class", "contentGroup"); if (_region.ShowTitle) { regionTitleControl = new HtmlGenericControl("div"); regionTitleControl.Attributes.Add("class", "contentGroupHeader"); regionTitleControl.InnerHtml = "<span class=\"contentGroupHeaderText\">" + _region.Title + "</span>"; regionControl.Controls.Add(regionTitleControl); } templateRegionControl.Controls.Add(regionControl); Provider _provider = new Content.Provider(_region.ProviderId); if (!string.IsNullOrEmpty(_provider.StyleSheet)) { Header.Controls.Add(new LiteralControl("<link ID=\"stylesheet\" rel=\"stylesheet\" type=\"text/css\" href=\"" + Page.ResolveUrl(_provider.StyleSheet) + "\" />")); } ProviderControl _providerControl = Page.LoadControl(_provider.ViewControl) as ProviderControl; _providerControl.PageId = _page.PageId; _providerControl.RegionId = _region.RegionId; _providerControl.ProviderId = _provider.ProviderId; regionControl.Controls.Add(_providerControl); } } } } base.OnInit(e); }