BaseValidatorDesigner.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WebForms / System / Web / UI / Design / WebControls / BaseValidatorDesigner.cs / 1 / BaseValidatorDesigner.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Web.UI.Design.WebControls { 
 
    using System.ComponentModel;
 
    using System.Web.UI.WebControls;

    /// 
    ///  
    ///    
    ///       Provides 
    ///       a designer for controls derived from ValidatorBase. 
    ///    
    ///  
    [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)]
    [SupportsPreviewControl(true)]
    public class BaseValidatorDesigner : PreviewControlDesigner {
 
        /// 
        ///  
        ///     
        ///       Gets the design time HTML of ValidatorBase controls.
        ///     
        /// 
        public override string GetDesignTimeHtml() {
            BaseValidator bv = (BaseValidator)ViewControl;
 
            // Set to false to force a render
            bv.IsValid = false; 
 
            // Put in dummy text if required
            string originalText  = bv.ErrorMessage; 
            ValidatorDisplay validatorDisplay = bv.Display;
            bool blank = (validatorDisplay == ValidatorDisplay.None || (originalText.Trim().Length == 0 && bv.Text.Trim().Length == 0));
            if (blank) {
                bv.ErrorMessage = "[" + bv.ID + "]"; 
                bv.Display = ValidatorDisplay.Static;
            } 
 
            string html = base.GetDesignTimeHtml();
 
            // Reset the control state
            if (blank) {
                bv.ErrorMessage = originalText;
                bv.Display = validatorDisplay; 
            }
 
            return html; 
        }
    } 
}


// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK