Export (0) Print
Expand All

BaseValidatorDesigner Class

Extends design-time behavior for controls that derive from BaseValidator.

For a list of all members of this type, see BaseValidatorDesigner Members.

System.Object
   System.ComponentModel.Design.ComponentDesigner
      System.Web.UI.Design.HtmlControlDesigner
         System.Web.UI.Design.ControlDesigner
            System.Web.UI.Design.WebControls.BaseValidatorDesigner

[Visual Basic]
Public Class BaseValidatorDesigner
   Inherits ControlDesigner
[C#]
public class BaseValidatorDesigner : ControlDesigner
[C++]
public __gc class BaseValidatorDesigner : public ControlDesigner
[JScript]
public class BaseValidatorDesigner extends ControlDesigner

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Example

[Visual Basic] The following code example creates a designer class, named SimpleCompareValidatorDesigner, that derives from the BaseValidatorDesigner class and is used to display a class, named SimpleCompareValidator, at design time. It overrides the GetDesignTimeHtml method to display the value of the validator's BaseValidator.ErrorMessage property at design time.

[Visual Basic] 
Imports System
Imports System.ComponentModel
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design
Imports System.Web.UI.Design.WebControls
Imports Examples.AspNet

Namespace Examples.AspNet.Design

    ' Create a class that derives from the
    ' BaseValidatorDesigner class that will 
    ' display a CustomCompareValidator class 
    ' at design time.
    Public Class SimpleCompareValidatorDesigner
        Inherits BaseValidatorDesigner
       
        ' Extend the GetDesignTimeHtml functionality to
        ' alter the design-time ForeColor if the Text
        ' property is defined.
         Overrides Public Function GetDesignTimeHtml() As String
             Dim cv As SimpleCompareValidator = _
                 CType(Component, SimpleCompareValidator)
             Dim designTimeHtml As String  
      
             ' Check the control's BorderStyle property
             ' to conditionally render design-time HTML.
             If (cv.BorderStyle = BorderStyle.NotSet) Then

                 ' Create variables to hold current property settings.
                 Dim oldBorderStyle As BorderStyle = cv.BorderStyle
                    
                 ' Set properties and the design-time HTML.
                 Try
                     cv.BorderStyle = BorderStyle.Solid              
                     designTimeHtml = MyBase.GetDesignTimeHtml()
                
                 ' If an exception occurs, call the GetErrorDesignTimeHtml
                 ' method.
                 Catch ex As Exception
                     designTimeHtml = GetErrorDesignTimeHtml(ex)

                 ' Return properties to their original settings.
                 Finally
                     cv.BorderStyle = oldBorderStyle
                 End Try
          
             Else
                 designTimeHtml = MyBase.GetDesignTimeHtml()
             End If
      
             Return designTimeHtml
         End Function
            
    End Class
End Namespace
           

[Visual Basic] The following code example uses the DesignerAttribute class to associate the SimpleCompareValidator class with the SimpleCompareValidatorDesigner class.

[Visual Basic] 
Imports System
Imports System.ComponentModel
Imports System.Web.UI.WebControls

' A class that uses the SimpleCompareValidatorDesigner
' to display its contents at design time.
Namespace Examples.AspNet
    
    <Designer(GetType(Examples.AspNet.Design.SimpleCompareValidatorDesigner))> _
    Public Class SimpleCompareValidator
      Inherits CompareValidator
        ' Enter code here for a custom
        ' CompareValidator class.
    End Class
End Namespace

[C#, C++, JScript] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Web.UI.Design.WebControls

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

Assembly: System.Design (in System.Design.dll)

See Also

BaseValidatorDesigner Members | System.Web.UI.Design.WebControls Namespace | BaseValidator

Show:
© 2014 Microsoft