示例#1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try {
            //1st save off the region
            _selectedRegion.Title = txtTitle.Text.Trim();
            _selectedRegion.ProviderId = int.Parse(ddlProvider.SelectedValue);
            _selectedRegion.TemplateRegionId = int.Parse(ddlTemplateRegion.SelectedValue);
            int sortOrder = 1;
            int.TryParse(txtSortOrder.Text, out sortOrder);
            _selectedRegion.SortOrder = sortOrder;
            _selectedRegion.ShowTitle = chkShowTitle.Checked;
            _selectedRegion.Save(WebUtility.GetUserName());

            //2nd join it up with the page
            int rowsAffected = new RegionController().JoinToPage(_selectedRegion.RegionId, pageId);

            Provider provider = new Provider(int.Parse(ddlProvider.SelectedValue));
            Response.Redirect(string.Format("~/admin/provider.aspx?pageId={0}&regionId={1}&providerId={2}", pageId, _selectedRegion.RegionId, provider.ProviderId), true);
              }
              catch (System.Threading.ThreadAbortException) {
              throw;
              }
              catch(Exception ex) {
            Logger.Error(typeof(region).Name, ex);
            Master.MessageCenter.DisplayCriticalMessage(ex.Message);
              }
        }
示例#2
0
 /// <summary>
 /// Loads the regions.
 /// </summary>
 /// <param name="pageId">The page id.</param>
 private void LoadRegions(int pageId)
 {
     RegionCollection regionCollection = new RegionController().FetchRegionsByPageId(pageId);
       if(regionCollection.Count > 0) {
     dgRegions.DataSource = regionCollection;
     dgRegions.ItemDataBound += new DataGridItemEventHandler(dgRegions_ItemDataBound);
     //dgRegions.Columns[0].HeaderText = LocalizationUtility.GetText("hdrMove");
     dgRegions.Columns[0].HeaderText = LocalizationUtility.GetText("hdrEditRegion");
     dgRegions.Columns[1].HeaderText = LocalizationUtility.GetText("hdrTemplateRegion");
     dgRegions.Columns[2].HeaderText = LocalizationUtility.GetText("hdrTitle");
     dgRegions.Columns[3].HeaderText = LocalizationUtility.GetText("hdrSortOrder");
     dgRegions.Columns[4].HeaderText = LocalizationUtility.GetText("hdrEdit");
     dgRegions.Columns[5].HeaderText = LocalizationUtility.GetText("hdrDelete");
     dgRegions.DataBind();
       } else {
     dgRegions.DataSource = null;
     dgRegions.DataBind();
       }
 }
示例#3
0
        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);
        }
示例#4
0
        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);
        }