protected void Page_Load(object sender, EventArgs e)
        {
            btnRefresh.Click += new EventHandler(btnRefresh_Click);
            Response.Cache.SetCacheability(HttpCacheability.Private);
            ActiveURL = ConfigurationSettings.AppSettings["ActiveURL"];
            if (!IsPostBack)
            {
                if (SessionData.Customer.CustomerID.Equals(string.Empty))
                {
                    Response.Redirect("Home.aspx");
                }

            }
            if (Request["CDID"] != null)
            {
                CDID = Request["CDID"].ToString();

                //create session based on CDID
                if (SessionData.Customer.CustomerID == null || SessionData.Customer.CustomerID == "")
                {
                    SessionData.Customer = new AppCustomer();
                    SessionData.Customer = canv.GetCustomerInfo(null, CDID, false);
                }
            }
            if (Request["TID"] != null)
            {
                templateID = Request["TID"].ToString();
                //tdLogout.Visible = true;
                //tdLogin.Visible = false;
                //tdSignup.Visible = false;
            }
            if (Request["Maint"] != null)
            {
                maint = Request["Maint"].ToString();
            }
            if (Request["CustomerName"] != null)
            {
                SessionData.Customer.SCustomerUserName = Convert.ToString(Request["CustomerName"]);
            }

            if (!IsPostBack)
            {
                if (Request["Appname"] != null)
                {
                    SessionData.Config = new AppConfiguration();
                    SessionData.Config.AppName = Convert.ToString(Request["Appname"]);
                }

                if (Request["Maint"] != null)
                {
                    //Fetch Campaign Info from AppConfiguration and AppProduct
                    FacebookBizProcess oFBBiz = new FacebookBizProcess();
                    SessionData.Config = oFBBiz.GetAppConfiguration(SessionData.Config.AppName, "");
                    SessionData.Product = oFBBiz.GetActiveAppProduct(null, SessionData.Config.DID);

                    oVidShareData = fbBiz.GetVideoShareData(SessionData.Config.DID);

                    //Now prefill all the values

                    txtCustomTabNamePromo2.Text = SessionData.Config.SCustomtTabName;

                    //Sweepstakes Details tab
                    txtHeaderText.Text = SessionData.Product.AppCaption;
                    txtVideoURL.Text = oVidShareData.SVideoShareURL;
                    txtDescription.Text = oVidShareData.SVideoShareDesc;
                    txtBannerURL.Text = SessionData.Product.SHeaderBannerURL;

                    if (SessionData.Product.ShareWidgetAdded.Equals(TRUE))
                    {
                        chkShareButton.Checked = true;
                    }
                    if (SessionData.Product.ReccWidgetAdded.Equals(TRUE))
                    {
                        chkRecc.Checked = true;
                    }
                    if (SessionData.Product.InquiryWidgetAdded.Equals(TRUE))
                    {
                        chkInquiry.Checked = true;
                        txtInquiryEmail.Visible = true;
                        txtInquiryEmail.Text = SessionData.Config.SInquiryEmail;
                    }
                    if (SessionData.Product.CommentsWidgetAdded.Equals(TRUE))
                    {
                        chkComment.Checked = true;
                    }
                    if (SessionData.Product.LikeWidgetAdded.Equals(TRUE))
                    {
                        chkLike.Checked = true;
                    }

                    string startDate = SessionData.Config.SAppStartDT;
                    string endDate = SessionData.Config.AppExpiryDT;

                    if (!string.IsNullOrEmpty(startDate))
                    {
                        DateTime sd = DateTime.Parse(startDate);
                        datepickerStart.Value = sd.ToString("dd/MM/yyyy");
                    }

                    if (!string.IsNullOrEmpty(endDate))
                    {
                        DateTime end = DateTime.Parse(endDate);
                        datepickerEnd.Value = end.ToString("dd/MM/yyyy");
                    }

                    if (SessionData.Product.LikeGatewayAdded.Equals(TRUE))
                    {
                        chkLikeGateway.Checked = true;
                        filePromo2LikeGateWayImage.Visible = true;
                    }

                    if (SessionData.Product.TwitterWidgetAdded.Equals(TRUE))
                    {
                        chkTweeter.Checked = true;

                    }
                }
            }

            if (hdnTabStatus.Value.Equals(STEP_ONE_COMPLETE))
            {
                HtmlGenericControl camp = new HtmlGenericControl();
                camp = (HtmlGenericControl)MainList.FindControl("CampDetails");
                camp.Style.Add("display", "block");

                HtmlGenericControl fbook = new HtmlGenericControl();
                fbook = (HtmlGenericControl)MainList.FindControl("FacebookDet");
                fbook.Style.Add("display", "none");

                HtmlGenericControl fbookShow = new HtmlGenericControl();
                fbookShow = (HtmlGenericControl)MainList.FindControl("Widgets");
                fbookShow.Style.Add("display", "none");

                StringBuilder oSBLastTab = new StringBuilder();
                oSBLastTab.Append(" $(document).ready(function () {");
                oSBLastTab.Append("$(\"#campDetLinker\").trigger('click')");
                oSBLastTab.Append("});");

                Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", oSBLastTab.ToString(), true);
            }
            else if (hdnTabStatus.Value.Equals(STEP_TWO_COMPLETE))
            {
                //Step two complete,
                HtmlGenericControl fbook = new HtmlGenericControl();
                fbook = (HtmlGenericControl)MainList.FindControl("FacebookDet");

                HtmlGenericControl camp = new HtmlGenericControl();
                camp = (HtmlGenericControl)MainList.FindControl("CampDetails");
                camp.Style.Add("display", "block");

                fbook.Style.Add("display", "none");

                HtmlGenericControl fbookShow = new HtmlGenericControl();
                fbookShow = (HtmlGenericControl)MainList.FindControl("Widgets");
                fbookShow.Style.Add("display", "block");

                StringBuilder oSBLastTab = new StringBuilder();
                oSBLastTab.Append(" $(document).ready(function () {");
                oSBLastTab.Append("$(\"#widgetLinker\").trigger('click')");
                oSBLastTab.Append("});");

                Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", oSBLastTab.ToString(), true);
            }
            else if (hdnTabStatus.Value.Equals(STEP_THREE_COMPLETE))
            {
                HtmlGenericControl fbook = new HtmlGenericControl();
                fbook = (HtmlGenericControl)MainList.FindControl("FacebookDet");

                HtmlGenericControl camp = new HtmlGenericControl();
                camp = (HtmlGenericControl)MainList.FindControl("CampDetails");
                camp.Style.Add("display", "block");

                fbook.Style.Add("display", "block");
                btnPreviewCampaign.Disabled = false;

                HtmlGenericControl fbookShow = new HtmlGenericControl();
                fbookShow = (HtmlGenericControl)MainList.FindControl("Widgets");
                fbookShow.Style.Add("display", "block");

                StringBuilder oSBLastTab = new StringBuilder();
                oSBLastTab.Append(" $(document).ready(function () {");
                oSBLastTab.Append("$(\"#fbLinker\").trigger('click')");
                oSBLastTab.Append("});");

                Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", oSBLastTab.ToString(), true);
            }
            else
            {
                HtmlGenericControl camp = new HtmlGenericControl();
                camp = (HtmlGenericControl)MainList.FindControl("CampDetails");
                camp.Style.Add("display", "block");

                HtmlGenericControl fbook = new HtmlGenericControl();
                fbook = (HtmlGenericControl)MainList.FindControl("FacebookDet");
                fbook.Style.Add("display", "none");

                HtmlGenericControl fbookShow = new HtmlGenericControl();
                fbookShow = (HtmlGenericControl)MainList.FindControl("Widgets");
                fbookShow.Style.Add("display", "none");
            }

            if (!string.IsNullOrEmpty(hdnCode.Value))
            {
                //Select page call
                Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "window.close();", true);
                framePage.Attributes.Add("src", "SelectPage.aspx?code=" + hdnCode.Value + "&app_id=" + hdnAppid.Value + "&Twitter=" + hdnTweetEnabled.Value);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            btnRefresh.Click += new EventHandler(btnRefresh_Click);
            Response.Cache.SetCacheability(HttpCacheability.Private);
            ActiveURL = ConfigurationSettings.AppSettings["ActiveURL"];

            if (Request["CDID"] != null)
            {
                CDID = Request["CDID"].ToString();
            }
            if (Request["TID"] != null)
            {
                templateID = Request["TID"].ToString();
            }

            if (Request["Maint"] != null)
            {
                maint = Request["Maint"].ToString();
            }
            if (Request["CustomerName"] != null)
            {
                SessionData.Customer.SCustomerUserName = Convert.ToString(Request["CustomerName"]);
            }

            if (Request["Appname"] != null)
            {
                if (string.IsNullOrEmpty(SessionData.Config.AppID))
                {
                    SessionData.Config = new AppConfiguration();
                    SessionData.Config.AppName = Convert.ToString(Request["Appname"]);
                }
            }

            if (!IsPostBack)
            {
                if (SessionData.Customer.CustomerID.Equals(string.Empty))
                {
                    Response.Redirect("Home.aspx");
                }
                //Fetch Campaign Info from AppConfiguration and AppProduct
                FacebookBizProcess oFBBiz = new FacebookBizProcess();
                SessionData.Config = oFBBiz.GetAppConfiguration(SessionData.Config.AppName, "");
                SessionData.Product = oFBBiz.GetActiveAppProduct(null, SessionData.Config.DID);
                SweepStakesData oSweepDataRetrieved = new SweepStakesData();
                oSweepDataRetrieved = oFBBiz.GetSweepDataForEditing(SessionData.Config.DID);

                //Now prefill all the values
                txtPrizeDetails.Text = oSweepDataRetrieved.SPRizeDetails;
                txtEligibility.Text = oSweepDataRetrieved.SEligibility;
                txtOffRules.Text = oSweepDataRetrieved.SSweeprules;
                txtPrivacy.Text = oSweepDataRetrieved.SSweepPrivacy;
                txtTandC.Text = oSweepDataRetrieved.SSweepTerms;
                ddlSelectWinner.SelectedValue = Convert.ToString(oSweepDataRetrieved.SSweepWinners);
                txtBannerURL.Text = SessionData.Product.SHeaderBannerURL;
                string stdt = oSweepDataRetrieved.SSweepStartDate;
                string edt = oSweepDataRetrieved.SSweepEndDate;
                string exdt = oSweepDataRetrieved.SSweepExpiryDate;

                if (!string.IsNullOrEmpty(stdt))
                {
                    DateTime sd = DateTime.Parse(stdt);
                    datepickerStart.Value = sd.ToString("dd/M/yyyy");
                }

                if (!string.IsNullOrEmpty(edt))
                {
                    DateTime end = DateTime.Parse(edt);
                    datepickerEnd.Value = end.ToString("dd/M/yyyy");
                }

                if (!string.IsNullOrEmpty(exdt))
                {
                    DateTime et = DateTime.Parse(exdt);
                    datepickerExpiry.Value = et.ToString("dd/M/yyyy");
                }

                //Sweepstakes Details tab
                txtHeaderText.Text = SessionData.Product.AppCaption;
                txtCustomTabNamePromo2.Text = SessionData.Config.SCustomtTabName;
                if (SessionData.Product.ShareWidgetAdded.Equals(TRUE))
                {
                    chkShareButton.Checked = true;
                }
                if (SessionData.Product.ReccWidgetAdded.Equals(TRUE))
                {
                    chkRecc.Checked = true;
                }
                if (SessionData.Product.InquiryWidgetAdded.Equals(TRUE))
                {
                    chkInquiry.Checked = true;
                }
                if (SessionData.Product.CommentsWidgetAdded.Equals(TRUE))
                {
                    chkComment.Checked = true;
                }
                if (SessionData.Product.LikeWidgetAdded.Equals(TRUE))
                {
                    chkLike.Checked = true;
                }

                if (SessionData.Product.LikeGatewayAdded.Equals(TRUE))
                {
                    chkLikeGateway.Checked = true;
                    filePromo2LikeGateWayImage.Visible = true;
                }
                if (SessionData.Product.TwitterWidgetAdded.Equals(TRUE))
                {
                    chkTweeter.Checked = true;

                }

                //Sweepstakes Details tab
                txtHeaderText.Text = SessionData.Product.AppCaption;

            }
            if (hdnTabStatus.Value.Equals(STEP_ONE_COMPLETE))
            {

                HtmlGenericControl camp = new HtmlGenericControl();
                camp = (HtmlGenericControl)MainList.FindControl("CampDetails");
                camp.Style.Add("display", "none");

                HtmlGenericControl fbook = new HtmlGenericControl();
                fbook = (HtmlGenericControl)MainList.FindControl("FacebookDet");
                fbook.Style.Add("display", "none");

                HtmlGenericControl fbookShow = new HtmlGenericControl();
                fbookShow = (HtmlGenericControl)MainList.FindControl("Widgets");
                fbookShow.Style.Add("display", "none");

                StringBuilder oSBLastTab = new StringBuilder();
                oSBLastTab.Append(" $(document).ready(function () {");
                oSBLastTab.Append("$(\"#campDetLinker\").trigger('click')");
                oSBLastTab.Append("});");

                Page.ClientScript.RegisterStartupScript(this.GetType(), "myStepOneScript", oSBLastTab.ToString(), true);
            }
            else if (hdnTabStatus.Value.Equals(STEP_TWO_COMPLETE))
            {
                //Step two complete,
                HtmlGenericControl fbook = new HtmlGenericControl();
                fbook = (HtmlGenericControl)MainList.FindControl("FacebookDet");

                HtmlGenericControl camp = new HtmlGenericControl();
                camp = (HtmlGenericControl)MainList.FindControl("CampDetails");
                camp.Style.Add("display", "block");

                fbook.Style.Add("display", "none");

                HtmlGenericControl fbookShow = new HtmlGenericControl();
                fbookShow = (HtmlGenericControl)MainList.FindControl("Widgets");
                fbookShow.Style.Add("display", "block");

                StringBuilder oSBLastTab = new StringBuilder();
                oSBLastTab.Append(" $(document).ready(function () {");
                oSBLastTab.Append("$(\"#widgetLinker\").trigger('click')");
                oSBLastTab.Append("});");

                Page.ClientScript.RegisterStartupScript(this.GetType(), "myStepTwoDesc", oSBLastTab.ToString(), true);
            }
            else if (hdnTabStatus.Value.Equals(STEP_THREE_COMPLETE))
            {

                //Step two complete,
                HtmlGenericControl fbook = new HtmlGenericControl();
                fbook = (HtmlGenericControl)MainList.FindControl("FacebookDet");

                HtmlGenericControl camp = new HtmlGenericControl();
                camp = (HtmlGenericControl)MainList.FindControl("CampDetails");
                camp.Style.Add("display", "block");

                fbook.Style.Add("display", "block");

                HtmlGenericControl fbookShow = new HtmlGenericControl();
                fbookShow = (HtmlGenericControl)MainList.FindControl("Widgets");
                fbookShow.Style.Add("display", "block");

                StringBuilder oSBLastTab = new StringBuilder();
                oSBLastTab.Append(" $(document).ready(function () {");
                oSBLastTab.Append("$(\"#fbLinker\").trigger('click')");
                oSBLastTab.Append("});");

                Page.ClientScript.RegisterStartupScript(this.GetType(), "myStepTthree", oSBLastTab.ToString(), true);

            }
            else
            {
                HtmlGenericControl camp = new HtmlGenericControl();
                camp = (HtmlGenericControl)MainList.FindControl("CampDetails");
                camp.Style.Add("display", "none");

                HtmlGenericControl fbook = new HtmlGenericControl();
                fbook = (HtmlGenericControl)MainList.FindControl("FacebookDet");
                fbook.Style.Add("display", "none");

                HtmlGenericControl fbookShow = new HtmlGenericControl();
                fbookShow = (HtmlGenericControl)MainList.FindControl("Widgets");
                fbookShow.Style.Add("display", "none");
            }

            if (!string.IsNullOrEmpty(hdnCode.Value))
            {
                //Select page call
                Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "window.close();", true);
                framePage.Attributes.Add("src", "SelectPage.aspx?code=" + hdnCode.Value + "&app_id=" + hdnAppid.Value + "&Twitter=" + hdnTweetEnabled.Value);
            }
        }