コード例 #1
0
 protected internal override void OnPreRender(EventArgs e)
 {
     base.OnPreRender(e);
     if (this.Enabled)
     {
         Page page = this.Page;
         if ((page != null) && (page.RequestInternal != null))
         {
             this.renderUplevel = (this.EnableClientScript && (page.Request.Browser.W3CDomVersion.Major >= 1)) && (page.Request.Browser.EcmaScriptVersion.CompareTo(new Version(1, 2)) >= 0);
         }
         if (this.renderUplevel)
         {
             string arrayValue = "document.getElementById(\"" + this.ClientID + "\")";
             if (!this.Page.IsPartialRenderingSupported)
             {
                 this.Page.ClientScript.RegisterArrayDeclaration("Page_ValidationSummaries", arrayValue);
             }
             else
             {
                 ValidatorCompatibilityHelper.RegisterArrayDeclaration(this, "Page_ValidationSummaries", arrayValue);
                 ValidatorCompatibilityHelper.RegisterStartupScript(this, typeof(ValidationSummary), this.ClientID + "_DisposeScript", string.Format(CultureInfo.InvariantCulture, "\r\ndocument.getElementById('{0}').dispose = function() {{\r\n    Array.remove({1}, document.getElementById('{0}'));\r\n}}\r\n", new object[] { this.ClientID, "Page_ValidationSummaries" }), true);
             }
         }
     }
 }
コード例 #2
0
        /// <devdoc>
        /// <para>Registers array declarations using the default array, <see langword='Page_Validators'/> .</para>
        /// </devdoc>
        protected virtual void RegisterValidatorDeclaration()
        {
            const string arrayName = "Page_Validators";
            string       element   = "document.getElementById(\"" + ClientID + "\")";

            // Cannot use the overloads of Register* that take a Control, since these methods only work with AJAX 3.5,
            // and we need to support Validators in AJAX 1.0 (Windows OS Bugs 2015831).
            if (!Page.IsPartialRenderingSupported)
            {
                Page.ClientScript.RegisterArrayDeclaration(arrayName, element);
            }
            else
            {
                ValidatorCompatibilityHelper.RegisterArrayDeclaration(this, arrayName, element);

                // Register a dispose script to make sure we clean up the page if we get destroyed
                // during an async postback.
                // We should technically use the ScriptManager.RegisterDispose() method here, but the original implementation
                // of Validators in AJAX 1.0 manually attached a dispose expando.  We added this code back in the product
                // late in the Orcas cycle, and we didn't want to take the risk of using RegisterDispose() instead.
                // (Windows OS Bugs 2015831)
                ValidatorCompatibilityHelper.RegisterStartupScript(this, typeof(BaseValidator), ClientID + "_DisposeScript",
                                                                   String.Format(
                                                                       CultureInfo.InvariantCulture,
                                                                       @"
document.getElementById('{0}').dispose = function() {{
    Array.remove({1}, document.getElementById('{0}'));
}}
",
                                                                       ClientID, arrayName), true);
            }
        }
コード例 #3
0
        /// <internalonly/>
        /// <devdoc>
        ///    PreRender method.
        /// </devdoc>
        protected internal override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            // Act like invisible if disabled
            if (!Enabled)
            {
                return;
            }

            // work out uplevelness now
            Page page = Page;

            if (page != null && page.RequestInternal != null)
            {
                renderUplevel = (EnableClientScript && ShowValidationErrors &&
                                 page.Request.Browser.W3CDomVersion.Major >= 1 &&
                                 page.Request.Browser.EcmaScriptVersion.CompareTo(new Version(1, 2)) >= 0);
            }
            if (renderUplevel && !IsUnobtrusive)
            {
                const string arrayName = "Page_ValidationSummaries";
                string       element   = "document.getElementById(\"" + ClientID + "\")";

                // Cannot use the overloads of Register* that take a Control, since these methods only work with AJAX 3.5,
                // and we need to support Validators in AJAX 1.0 (Windows OS Bugs 2015831).
                if (!Page.IsPartialRenderingSupported)
                {
                    Page.ClientScript.RegisterArrayDeclaration(arrayName, element);
                }
                else
                {
                    ValidatorCompatibilityHelper.RegisterArrayDeclaration(this, arrayName, element);

                    // Register a dispose script to make sure we clean up the page if we get destroyed
                    // during an async postback.
                    // We should technically use the ScriptManager.RegisterDispose() method here, but the original implementation
                    // of Validators in AJAX 1.0 manually attached a dispose expando.  We added this code back in the product
                    // late in the Orcas cycle, and we didn't want to take the risk of using RegisterDispose() instead.
                    // (Windows OS Bugs 2015831)
                    ValidatorCompatibilityHelper.RegisterStartupScript(this, typeof(ValidationSummary), ClientID + "_DisposeScript",
                                                                       String.Format(
                                                                           CultureInfo.InvariantCulture,
                                                                           @"
(function(id) {{
    var e = document.getElementById(id);
    if (e) {{
        e.dispose = function() {{
            Array.remove({1}, document.getElementById(id));
        }}
        e = null;
    }}
}})('{0}');
",
                                                                           ClientID, arrayName), true);
                }
            }
        }
コード例 #4
0
        protected virtual void RegisterValidatorDeclaration()
        {
            string arrayValue = "document.getElementById(\"" + this.ClientID + "\")";

            if (!this.Page.IsPartialRenderingSupported)
            {
                this.Page.ClientScript.RegisterArrayDeclaration("Page_Validators", arrayValue);
            }
            else
            {
                ValidatorCompatibilityHelper.RegisterArrayDeclaration(this, "Page_Validators", arrayValue);
                ValidatorCompatibilityHelper.RegisterStartupScript(this, typeof(BaseValidator), this.ClientID + "_DisposeScript", string.Format(CultureInfo.InvariantCulture, "\r\ndocument.getElementById('{0}').dispose = function() {{\r\n    Array.remove({1}, document.getElementById('{0}'));\r\n}}\r\n", new object[] { this.ClientID, "Page_Validators" }), true);
            }
        }