예제 #1
0
        /// <summary>
        /// Registers the client side script for the control.
        /// </summary>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            if (!AnthemNxt.Core.Manager.IsCallBack)
            {
                // Always register the var that will track the timer.
                string script = string.Format("<script type=\"text/javascript\">var {0}_timer = null;</script>", this.ClientID);
                Page.ClientScript.RegisterStartupScript(this.GetType(), script, script, false);

                // For the initial page load, register the timer script so that it loads after
                // the page is finished loading.
                if (Enabled)
                {
                    script = string.Format("<script type=\"text/javascript\">{0}</script>", GetSetTimeoutScript());
                    Page.ClientScript.RegisterStartupScript(this.GetType(), script, script, false);
                }
            }
            else if (_addTimeoutScript)
            {
                // If this is a callback, add a script to call the timer again or to stop the timer.
                if (Enabled)
                {
                    ScriptManager.AddScriptForClientSideEval(GetSetTimeoutScript());
                }
                else
                {
                    ScriptManager.AddScriptForClientSideEval(GetClearTimeoutScript());
                }
            }
        }
예제 #2
0
        /// <summary>
        /// If ShowMessageBox=true, use AnthemNxt.Manager to display the validation
        /// summary in a javascript alert.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            bool isValid = true;

            foreach (IValidator validator in Page.Validators)
            {
                isValid &= validator.IsValid;
            }

            if (AnthemNxt.Core.Manager.IsCallBack &&
                !isValid &&
                this.ShowMessageBox &&
                this.EnableCallBackScript)
            {
                string s = string.Empty;
                if (this.HeaderText != null && this.HeaderText != string.Empty)
                {
                    s += this.HeaderText + "\\n";
                }
                int count = 0;
                foreach (ASP.BaseValidator validator in Page.Validators)
                {
                    if (
                        ((
                             (this.ValidationGroup == null || this.ValidationGroup == string.Empty) &&
                             (validator.ValidationGroup == null || validator.ValidationGroup == string.Empty)
                             )
                         ||
                         (
                             (this.ValidationGroup != null && this.ValidationGroup != string.Empty) &&
                             (validator.ValidationGroup != null && validator.ValidationGroup == this.ValidationGroup)
                         )) &&
                        !validator.IsValid &&
                        validator.ErrorMessage != null &&
                        validator.ErrorMessage != string.Empty)
                    {
                        count++;
                        switch (this.DisplayMode)
                        {
                        case System.Web.UI.WebControls.ValidationSummaryDisplayMode.List:
                            s += validator.ErrorMessage + "\\n";
                            break;

                        case System.Web.UI.WebControls.ValidationSummaryDisplayMode.BulletList:
                        default:
                            s += "  - " + validator.ErrorMessage + "\\n";
                            break;

                        case System.Web.UI.WebControls.ValidationSummaryDisplayMode.SingleParagraph:
                            s += validator.ErrorMessage + " ";
                            break;
                        }
                    }
                }
                if (count > 0)
                {
                    ScriptManager.AddScriptForClientSideEval("alert('" + s + "');");
                }
            }
        }
예제 #3
0
 private void UpdateAndReAddWebParts()
 {
     UpdateAfterCallBack = true;
     ScriptManager.AddScriptForClientSideEval(string.Format("ReAddWebParts('{0}')", ID));
 }