SurveyPageEdit.aspx.cs :  » Content-Management-Systems-CMS » mojoPortal » SurveyFeature » UI » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Content Management Systems CMS » mojoPortal 
mojoPortal » SurveyFeature » UI » SurveyPageEdit.aspx.cs
/// Author:          Rob Henry
/// Created:        2007-09-09
/// Last Modified:      2008-01-21
/// 
/// The use and distribution terms for this software are covered by the 
/// Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
/// which can be found in the file CPL.TXT at the root of this distribution.
/// By using this software in any fashion, you are agreeing to be bound by 
/// the terms of this license.
///
/// You must not remove this notice, or any other, from this software.

using System;
using System.Globalization;
using System.Web.UI;
using mojoPortal.Web;
using mojoPortal.Web.Framework;
using SurveyFeature.Business;
using Resources;

namespace SurveyFeature.UI{
    public partial class PageEditPage : mojoBasePage
    {
        private Guid surveyGuid = Guid.Empty;
        private Survey survey = null;
        private Guid surveyPageGuid = Guid.Empty;
        private SurveyFeature.Business.Page surveyPage;
        
        private int pageId;
        private int moduleId;

        #region public properties

        public int PageId
        {
            get
            {
                return pageId;
            }
        }

        public int ModuleId
        {
            get
            {
                return moduleId;
            }
        }

        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Request.IsAuthenticated)
            {
                SiteUtils.RedirectToLoginPage(this);
                return;
            }

            SecurityHelper.DisableBrowserCache();

            LoadSettings();

            if (!UserCanEditModule(moduleId))
            {
                SiteUtils.RedirectToEditAccessDeniedPage();
                return;
            }

            PopulateLabels();

            PopulateControls();
                
            
        }

        private void PopulateControls()
        {
            
            if (survey != null)
            {
                if (surveyPage != null)
                {
                    litHeading.Text = string.Format(CultureInfo.InvariantCulture,
                        SurveyResources.PageEditFormatString,
                        survey.SurveyName);
                }
                else
                {
                     litHeading.Text = string.Format(CultureInfo.InvariantCulture,
                    SurveyResources.PageEditNewPageFormatString,
                    survey.SurveyName);

                }

                lnkPages.Text = string.Format(CultureInfo.InvariantCulture,
                SurveyResources.SurveyPagesLabelFormatString,
                survey.SurveyName);
            }

            
            
            
            if (Page.IsPostBack) return;

            if (surveyPage != null)
            {
                txtPageTitle.Text = surveyPage.PageTitle;
                chkPageEnabled.Checked = surveyPage.PageEnabled;
            }
            

        }

        private void PopulateLabels()
        {
            lnkPageCrumb.Text = CurrentPage.PageName;
            lnkPageCrumb.NavigateUrl = SiteUtils.GetCurrentPageUrl();

            lnkSurveys.Text = SurveyResources.SurveyBreadCrumbText;
            lnkSurveys.NavigateUrl = SiteRoot +"/Survey/Surveys.aspx?pageid=" 
                + pageId.ToInvariantString()
                + "&mid=" + moduleId.ToInvariantString();

            lnkPages.NavigateUrl = SiteRoot
                + "/Survey/SurveyPages.aspx?SurveyGuid="
                + surveyGuid.ToString() + "&pageid=" + pageId.ToInvariantString()
                + "&mid=" + ModuleId.ToInvariantString();

            lnkPageEdit.Text = SurveyResources.SurveyPageEditBreadCrumbText;
            lnkPageEdit.NavigateUrl = Request.RawUrl;

            

            btnSave.Text = SurveyResources.PageEditSaveButton;
            btnSave.ToolTip = SurveyResources.PageEditSaveButtonToolTip;
            btnCancel.Text = SurveyResources.PageEditCancelButton;
            btnCancel.ToolTip = SurveyResources.PageEditCancelButtonToolTip;
        }

        private void LoadSettings()
        {
            pageId = WebUtils.ParseInt32FromQueryString("pageid", -1);
            surveyPageGuid = WebUtils.ParseGuidFromQueryString("SurveyPageGuid", Guid.Empty);
            moduleId = WebUtils.ParseInt32FromQueryString("mid", true, -1);
            
            if (surveyPageGuid == Guid.Empty)
            {
                surveyGuid = WebUtils.ParseGuidFromQueryString("SurveyGuid", Guid.Empty);
            }
            else
            {
                surveyPage = new SurveyFeature.Business.Page(surveyPageGuid);
                surveyGuid = surveyPage.SurveyGuid;
            }



            if (surveyGuid != Guid.Empty)
            {
                survey = new Survey(surveyGuid);
                if (survey.SiteGuid != siteSettings.SiteGuid)
                {
                    surveyGuid = Guid.Empty;
                    survey = null;

                    surveyPageGuid = Guid.Empty;
                    surveyPage = null;
                    
                }
            }
        }

        

        private void SavePage(SurveyFeature.Business.Page page)
        {
            page.PageTitle = txtPageTitle.Text;
            page.PageEnabled = chkPageEnabled.Checked;
            
            if (surveyPageGuid == Guid.Empty)
            {
                //new question so we need to know the page it will live on
                page.SurveyGuid = surveyGuid;
            }

            page.Save();
        }

        #region Events

        void BtnCancel_Click(object sender, EventArgs e)
        {
            Guid redirectSurveyGuid = Guid.Empty;

            if (surveyPageGuid == Guid.Empty)
            {
                redirectSurveyGuid = surveyGuid;
            }
            else
            {
                SurveyFeature.Business.Page page = new SurveyFeature.Business.Page(surveyPageGuid);
                redirectSurveyGuid = page.SurveyGuid;
            }

            WebUtils.SetupRedirect(this, SiteRoot + "/Survey/SurveyPages.aspx?SurveyGuid=" 
                + redirectSurveyGuid.ToString() + "&pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString());
        }

        protected void BtnSave_Click(object sender, EventArgs e)
        {
            Page.Validate();
            if (Page.IsValid)
            {
                SurveyFeature.Business.Page page = new SurveyFeature.Business.Page(surveyPageGuid);
                SavePage(page);

                WebUtils.SetupRedirect(this, SiteRoot + "/Survey/SurveyPages.aspx?SurveyGuid=" 
                    + page.SurveyGuid.ToString() + "&pageid=" + pageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString());
            }
        }

        #endregion

        #region OnInit

        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this.Load += new EventHandler(Page_Load);
            this.btnSave.Click += new EventHandler(BtnSave_Click);
            this.btnCancel.Click +=new EventHandler(BtnCancel_Click);

            SuppressPageMenu();
            
        }

        #endregion

    }
}

www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.