DetailsViewDesigner Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides design-time support in a visual designer for the DetailsView control.
public ref class DetailsViewDesigner : System::Web::UI::Design::WebControls::DataBoundControlDesigner
public class DetailsViewDesigner : System.Web.UI.Design.WebControls.DataBoundControlDesigner
type DetailsViewDesigner = class
inherit DataBoundControlDesigner
Public Class DetailsViewDesigner
Inherits DataBoundControlDesigner
- Inheritance
Examples
The following code example shows how to extend the DetailsViewDesigner class to change the appearance of controls that are derived from the DetailsView control at design time.
The example derives the MyDetailsView
control from the DetailsView. The MyDetailsView
is simply a copy of the DetailsView control. The example also derives the MyDetailsViewDesigner
class from DetailsViewDesigner and places a DesignerAttribute object for MyDetailsViewDesigner
on the MyDetailsView
control.
The MyDetailsViewDesigner
overrides the SampleRowCount property to specify that the pager row of the design-time view of the MyDetailsView
contain five page links. It overrides the PreFilterProperties method to make the NamingContainer property visible in the Property grid at design time. It overrides the GetDesignTimeHtml method to include the Caption property, if it is specified, as a new first row in the MyDetailsView
grid at design time. If the BorderStyle property of the MyDetailsView
is the NotSet or None value, the GetDesignTimeHtml draws a blue dashed border around the control to make its extent more visible.
using System;
using System.Web;
using System.Drawing;
using System.Web.UI.WebControls;
using System.Web.UI.Design.WebControls;
using System.Collections;
using System.ComponentModel;
using System.Security.Permissions;
namespace Examples.CS.WebControls.Design
{
// The MyDetailsView is a copy of the DetailsView.
[AspNetHostingPermission(SecurityAction.Demand,
Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand,
Level = AspNetHostingPermissionLevel.Minimal)]
[Designer(typeof(Examples.CS.WebControls.Design.MyDetailsViewDesigner))]
public class MyDetailsView : DetailsView
{
} // MyDetailsView
// Override members of the DetailsViewDesigner.
[ReflectionPermission(SecurityAction.Demand, Flags=ReflectionPermissionFlag.MemberAccess)]
public class MyDetailsViewDesigner : DetailsViewDesigner
{
// Determines the number of page links in the pager row
// when viewed in the designer.
protected override int SampleRowCount
{
get
{
// Render five page links in the pager row.
return 5;
}
} // SampleRowCount
// Shadow the control properties with design-time properties.
protected override void PreFilterProperties(IDictionary properties)
{
// Call the base method first.
base.PreFilterProperties(properties);
// Make the NamingContainer visible in the Properties grid.
PropertyDescriptor selectProp =
(PropertyDescriptor)properties["NamingContainer"];
properties["NamingContainer"] =
TypeDescriptor.CreateProperty(selectProp.ComponentType,
selectProp, BrowsableAttribute.Yes);
} // PreFilterProperties
// Generate the design-time markup.
const string capTag = "caption";
const string trOpen = "tr><td colspan=2 align=center";
const string trClose = "td></tr";
public override string GetDesignTimeHtml()
{
// Make the full extent of the control more visible in the designer.
// If the border style is None or NotSet, change the border to
// a wide, blue, dashed line. Include the caption within the border.
MyDetailsView myDV = (MyDetailsView)Component;
string markup = null;
int charX;
// Check if the border style should be changed.
if (myDV.BorderStyle == BorderStyle.NotSet ||
myDV.BorderStyle == BorderStyle.None)
{
BorderStyle oldBorderStyle = myDV.BorderStyle;
Unit oldBorderWidth = myDV.BorderWidth;
Color oldBorderColor = myDV.BorderColor;
// Set design-time properties and catch any exceptions.
try
{
myDV.BorderStyle = BorderStyle.Dashed;
myDV.BorderWidth = Unit.Pixel(3);
myDV.BorderColor = Color.Blue;
// Call the base method to generate the markup.
markup = base.GetDesignTimeHtml();
}
catch (Exception ex)
{
markup = GetErrorDesignTimeHtml(ex);
}
finally
{
// Restore the properties to their original settings.
myDV.BorderStyle = oldBorderStyle;
myDV.BorderWidth = oldBorderWidth;
myDV.BorderColor = oldBorderColor;
}
}
else
{
// Call the base method to generate the markup.
markup = base.GetDesignTimeHtml();
}
// Look for a <caption> tag.
if ((charX = markup.IndexOf(capTag)) > 0)
{
// Replace the first caption with
// "tr><td colspan=2 align=center".
markup = markup.Remove(charX,
capTag.Length).Insert(charX, trOpen);
// Replace the second caption with "td></tr".
if ((charX = markup.IndexOf(capTag, charX)) > 0)
markup = markup.Remove(charX,
capTag.Length).Insert(charX, trClose);
}
return markup;
} // GetDesignTimeHtml
} // MyDetailsViewDesigner
} // Examples.CS.WebControls.Design
Imports System.Web
Imports System.Drawing
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design.WebControls
Imports System.Collections
Imports System.ComponentModel
Imports System.Security.Permissions
Namespace Examples.VB.WebControls.Design
' The MyDetailsView is a copy of the DetailsView.
<AspNetHostingPermission(SecurityAction.Demand, _
Level:=AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermission(SecurityAction.InheritanceDemand, _
Level:=AspNetHostingPermissionLevel.Minimal)> _
<Designer(GetType(Examples.VB.WebControls.Design.MyDetailsViewDesigner))> _
Public Class MyDetailsView
Inherits DetailsView
End Class
' Override members of the DetailsViewDesigner.
<ReflectionPermission(SecurityAction.Demand, Flags:=ReflectionPermissionFlag.MemberAccess)> _
Public Class MyDetailsViewDesigner
Inherits DetailsViewDesigner
' Determines the number of page links in the pager row
' when viewed in the designer.
Protected Overrides ReadOnly Property SampleRowCount() As Integer
Get
' Render five page links in the pager row.
Return 5
End Get
End Property ' SampleRowCount
' Shadow the control properties with design-time properties.
Protected Overrides Sub PreFilterProperties( _
ByVal properties As IDictionary)
' Call the base method first.
MyBase.PreFilterProperties(properties)
' Make the NamingContainer visible in the Properties grid.
Dim selectProp As PropertyDescriptor = _
CType(properties("NamingContainer"), PropertyDescriptor)
properties("NamingContainer") = _
TypeDescriptor.CreateProperty(selectProp.ComponentType, _
selectProp, BrowsableAttribute.Yes)
End Sub
' Generate the design-time markup.
Private Const capTag As String = "caption"
Private Const trOpen As String = "tr><td colspan=2 align=center"
Private Const trClose As String = "td></tr"
Public Overrides Function GetDesignTimeHtml() As String
' Make the full extent of the control more visible in the designer.
' If the border style is None or NotSet, change the border to
' a wide, blue, dashed line. Include the caption within the border.
Dim myDV As MyDetailsView = CType(Component, MyDetailsView)
Dim markup As String = Nothing
Dim charX As Integer
' Check if the border style should be changed.
If (myDV.BorderStyle = BorderStyle.NotSet Or _
myDV.BorderStyle = BorderStyle.None) Then
Dim oldBorderStyle As BorderStyle = myDV.BorderStyle
Dim oldBorderWidth As Unit = myDV.BorderWidth
Dim oldBorderColor As Color = myDV.BorderColor
' Set design-time properties and catch any exceptions.
Try
myDV.BorderStyle = BorderStyle.Dashed
myDV.BorderWidth = Unit.Pixel(3)
myDV.BorderColor = Color.Blue
' Call the base method to generate the markup.
markup = MyBase.GetDesignTimeHtml()
Catch ex As Exception
markup = GetErrorDesignTimeHtml(ex)
Finally
' Restore the properties to their original settings.
myDV.BorderStyle = oldBorderStyle
myDV.BorderWidth = oldBorderWidth
myDV.BorderColor = oldBorderColor
End Try
Else
' Call the base method to generate the markup.
markup = MyBase.GetDesignTimeHtml()
End If
' Look for a <caption> tag.
charX = markup.IndexOf(capTag)
If charX > 0 Then
' Replace the first caption with
' "tr><td colspan=2 align=center".
markup = markup.Remove(charX, _
capTag.Length).Insert(charX, trOpen)
' Replace the second caption with "td></tr".
charX = markup.IndexOf(capTag, charX)
If charX > 0 Then
markup = markup.Remove(charX, _
capTag.Length).Insert(charX, trClose)
End If
End If
Return markup
End Function ' GetDesignTimeHtml
End Class
End Namespace ' Examples.VB.WebControls.Design
Remarks
In a visual designer, when you switch from Source to Design view, the markup source code that describes the DetailsView control is parsed and a design-time version of the control is created on the design surface. When you switch back to Source view, the design-time control is persisted to markup source code and edited into the markup for the Web page.
The properties of the DetailsViewDesigner class provide the following functionality:
The ActionLists property returns a DesignerActionListCollection object, which typically contains an object that is derived from the DesignerActionList class for each level in the inheritance tree of the designer.
The AutoFormats property returns a collection of formatting schemes for display in the Auto Format dialog box.
The TemplateGroups property returns a collection of template groups for the fields of the associated DetailsView control and the top level DetailsView templates.
The UsePreviewControl property always returns
true
, indicating that the designer creates a temporary copy of the associated DetailsView control to generate the design-time markup.
The DetailsViewDesigner class methods provide the following functionality:
The DataBind method binds the associated DetailsView control to a design-time data source.
The GetDesignTimeHtml method returns the markup that is used to render the associated DetailsView at design time.
The Initialize method prepares the designer to view, edit, and design the associated DetailsView.
The OnClick method is called when a region of the design-time view of the associated DetailsView is clicked.
The OnSchemaRefreshed method is called when the schema of the data source of the associated DetailsView changes.
The PreFilterProperties method is used to remove or add additional properties or to shadow properties of the associated DetailsView.
Design-time editable regions are not supported in the DetailsView control, so the GetEditableDesignerRegionContent and SetEditableDesignerRegionContent methods have no functionality.
Constructors
DetailsViewDesigner() |
Initializes a new instance of the DetailsViewDesigner class. |
Properties
ActionLists |
Gets the designer action list collection for this designer. |
AllowResize |
Gets a value indicating whether the control can be resized in the design-time environment. (Inherited from ControlDesigner) |
AssociatedComponents |
Gets the collection of components associated with the component managed by the designer. (Inherited from ComponentDesigner) |
AutoFormats |
Gets the collection of automatic formatting schemes to display in the Auto Format dialog box. |
Behavior |
Obsolete.
Gets or sets the DHTML behavior that is associated with the designer. (Inherited from HtmlControlDesigner) |
Component |
Gets the component this designer is designing. (Inherited from ComponentDesigner) |
DataBindings |
Gets the data bindings collection for the current control. (Inherited from HtmlControlDesigner) |
DataBindingsEnabled |
Gets a value indicating whether data binding is supported by the containing region for the associated control. (Inherited from ControlDesigner) |
DataMember |
Gets the shadowed DataMember property of the underlying data-bound control. (Inherited from DataBoundControlDesigner) |
DataSource |
Gets or sets the value of the DataSource property for the associated control. (Inherited from BaseDataBoundControlDesigner) |
DataSourceDesigner |
Gets the designer of the data source of the underlying data-bound control. (Inherited from DataBoundControlDesigner) |
DataSourceID |
Gets or sets the value of the DataSourceID property of the underlying BaseDataBoundControl object. (Inherited from BaseDataBoundControlDesigner) |
DesignerState |
Gets an object that is used to persist data for the associated control at design time. (Inherited from ControlDesigner) |
DesignerView |
Gets the DesignerDataSourceView object associated with the data source of this designer. (Inherited from DataBoundControlDesigner) |
DesignTimeElement |
Obsolete.
Gets the design-time object representing the control that is associated with the HtmlControlDesigner object on the design surface. (Inherited from HtmlControlDesigner) |
DesignTimeElementView |
Obsolete.
Gets the view-control object for the control designer. (Inherited from ControlDesigner) |
DesignTimeHtmlRequiresLoadComplete |
Obsolete.
Gets a value indicating whether the design host must finish loading before the GetDesignTimeHtml method can be called. (Inherited from ControlDesigner) |
Expressions |
Gets the expression bindings for the current control at design time. (Inherited from HtmlControlDesigner) |
HidePropertiesInTemplateMode |
Gets a value indicating whether the properties of the associated control are hidden when the control is in template mode. (Inherited from ControlDesigner) |
ID |
Gets or sets the ID string for the control. (Inherited from ControlDesigner) |
InheritanceAttribute |
Gets an attribute that indicates the type of inheritance of the associated component. (Inherited from ComponentDesigner) |
Inherited |
Gets a value indicating whether this component is inherited. (Inherited from ComponentDesigner) |
InTemplateMode |
Gets a value indicating whether the control is in either template viewing or editing mode in the design host. The InTemplateMode property is read-only. (Inherited from ControlDesigner) |
IsDirty |
Obsolete.
Gets or sets a value indicating whether the Web server control has been marked as changed. (Inherited from ControlDesigner) |
ParentComponent |
Gets the parent component for this designer. (Inherited from ComponentDesigner) |
ReadOnly |
Obsolete.
Gets or sets a value indicating whether the properties of the control are read-only at design time. (Inherited from ControlDesigner) |
RootDesigner |
Gets the control designer for the Web Forms page that contains the associated control. (Inherited from ControlDesigner) |
SampleRowCount |
Gets the number of sample rows for the associated control to display. |
SetTextualDefaultProperty | (Inherited from ComponentDesigner) |
ShadowProperties |
Gets a collection of property values that override user settings. (Inherited from ComponentDesigner) |
ShouldCodeSerialize |
Obsolete.
Gets or sets a value indicating whether to create a field declaration for the control in the code-behind file for the current design document during serialization. (Inherited from HtmlControlDesigner) |
Tag |
Gets an object representing the HTML markup element for the associated control. (Inherited from ControlDesigner) |
TemplateGroups |
Gets a collection of template groups for the fields of the associated control. |
UseDataSourcePickerActionList |
Gets a value indicating whether the designer should include "Choose a data source" in its action list. (Inherited from DataBoundControlDesigner) |
UsePreviewControl |
Gets a value indicating whether the designer should use a temporary copy, rather than the actual control associated with the designer, to generate the design-time markup. |
Verbs |
Gets the design-time verbs supported by the component that is associated with the designer. (Inherited from ComponentDesigner) |
ViewControl |
Gets or sets a Web server control that can be used for previewing the design-time HTML markup. (Inherited from ControlDesigner) |
ViewControlCreated |
Gets or sets a value indicating whether a |
Visible |
Gets a value that indicates whether the control is visible at design time. (Inherited from ControlDesigner) |
Methods
ConnectToDataSource() |
Disconnects events from the previous data source and connects them to the current data source. (Inherited from DataBoundControlDesigner) |
CreateDataSource() |
Invokes the standard dialog box to create a new data source control, and sets the new data source control's ID to the DataSourceID property of the data-bound control. (Inherited from DataBoundControlDesigner) |
CreateErrorDesignTimeHtml(String, Exception) |
Creates the HTML markup to display a specified exception error message at design time. (Inherited from ControlDesigner) |
CreateErrorDesignTimeHtml(String) |
Creates HTML markup to display a specified error message at design time. (Inherited from ControlDesigner) |
CreatePlaceHolderDesignTimeHtml() |
Provides a simple rectangular placeholder representation that displays the type and ID of the control. (Inherited from ControlDesigner) |
CreatePlaceHolderDesignTimeHtml(String) |
Provides a simple rectangular placeholder representation that displays the type and ID of the control, and also additional specified instructions or information. (Inherited from ControlDesigner) |
CreateViewControl() |
Returns a copy of the associated control for viewing or rendering on the design surface. (Inherited from ControlDesigner) |
DataBind(BaseDataBoundControl) |
Binds the associated control to the design-time data source. |
DisconnectFromDataSource() |
Disconnects the data-bound control from data source events. (Inherited from DataBoundControlDesigner) |
Dispose() |
Releases all resources used by the ComponentDesigner. (Inherited from ComponentDesigner) |
Dispose(Boolean) |
Releases the unmanaged resources used by the DataBoundControlDesigner object and optionally releases the managed resources. (Inherited from DataBoundControlDesigner) |
DoDefaultAction() |
Creates a method signature in the source code file for the default event on the component and navigates the user's cursor to that location. (Inherited from ComponentDesigner) |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetBounds() |
Retrieves the coordinates of the rectangle representing the boundaries for the control as displayed on the design surface. (Inherited from ControlDesigner) |
GetDesignTimeDataSource() |
Gets the design-time data source from either the associated |
GetDesignTimeHtml() |
Gets the markup that is used to render the associated control at design time. |
GetDesignTimeHtml(DesignerRegionCollection) |
Gets the markup that is used to render the associated control at design time and populates a collection of designer regions. |
GetEditableDesignerRegionContent(EditableDesignerRegion) |
Returns the content for an editable region of the design-time view of the associated control. |
GetEmptyDesignTimeHtml() |
Provides the markup that is used to render the control at design time if the control is empty or if the data source cannot be retrieved. (Inherited from BaseDataBoundControlDesigner) |
GetErrorDesignTimeHtml(Exception) |
Provides the markup that is used to render the control at design time when an error has occurred. (Inherited from BaseDataBoundControlDesigner) |
GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
GetPersistenceContent() |
Retrieves the persistable inner HTML markup of the control at design time. (Inherited from ControlDesigner) |
GetPersistInnerHtml() |
Obsolete.
Retrieves the persistable inner HTML markup of the control. (Inherited from ControlDesigner) |
GetSampleDataSource() |
Gets dummy sample data to render the data-bound control on the design surface if sample data cannot be created from the |
GetService(Type) |
Attempts to retrieve the specified type of service from the design mode site of the designer's component. (Inherited from ComponentDesigner) |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
GetViewRendering() |
Retrieves an object that contains the design-time markup for the content and regions of the associated control. (Inherited from ControlDesigner) |
Initialize(IComponent) |
Prepares the designer to view, edit, and design the associated control. |
InitializeExistingComponent(IDictionary) |
Reinitializes an existing component. (Inherited from ComponentDesigner) |
InitializeNewComponent(IDictionary) |
Initializes a newly created component. (Inherited from ComponentDesigner) |
InitializeNonDefault() |
Obsolete.
Obsolete.
Initializes the settings for an imported component that is already initialized to settings other than the defaults. (Inherited from ComponentDesigner) |
Invalidate() |
Invalidates the whole area of the control that is displayed on the design surface and signals the control designer to redraw the control. (Inherited from ControlDesigner) |
Invalidate(Rectangle) |
Invalidates the specified area of the control that is displayed on the design surface and signals the control designer to redraw the control. (Inherited from ControlDesigner) |
InvokeGetInheritanceAttribute(ComponentDesigner) |
Gets the InheritanceAttribute of the specified ComponentDesigner. (Inherited from ComponentDesigner) |
IsPropertyBound(String) |
Obsolete.
Retrieves a value indicating whether the specified property on the associated control is data-bound. (Inherited from ControlDesigner) |
Localize(IDesignTimeResourceWriter) |
Uses the provided resource writer to persist the localizable properties of the associated control to a resource in the design host. (Inherited from ControlDesigner) |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
OnAutoFormatApplied(DesignerAutoFormat) |
Called when a predefined, automatic formatting scheme has been applied to the associated control. (Inherited from ControlDesigner) |
OnBehaviorAttached() |
Called when the control designer is attached to a Behavior object. (Inherited from ControlDesigner) |
OnBehaviorDetaching() |
Obsolete.
Called when a behavior disassociates from the element. (Inherited from HtmlControlDesigner) |
OnBindingsCollectionChanged(String) |
Obsolete.
Called when the data-binding collection changes. (Inherited from ControlDesigner) |
OnClick(DesignerRegionMouseEventArgs) |
Called when a region of the design-time view for the associated control is clicked. |
OnComponentChanged(Object, ComponentChangedEventArgs) |
Called when the associated control changes. (Inherited from ControlDesigner) |
OnComponentChanging(Object, ComponentChangingEventArgs) |
Represents the method that will handle the ComponentChanging event for the associated control. (Inherited from ControlDesigner) |
OnControlResize() |
Obsolete.
Called when the associated Web server control has been resized in the design host at design time. (Inherited from ControlDesigner) |
OnDataSourceChanged(Boolean) |
Called when the data source of the associated BaseDataBoundControl object changes. (Inherited from BaseDataBoundControlDesigner) |
OnPaint(PaintEventArgs) |
Called when the control designer draws the associated control on the design surface, if the CustomPaint value is |
OnSchemaRefreshed() |
Called when the schema of the data source for the associated control changes. |
OnSetComponentDefaults() |
Obsolete.
Obsolete.
Sets the default properties for the component. (Inherited from ComponentDesigner) |
OnSetParent() |
Provides a way to perform additional processing when the associated control is attached to a parent control. (Inherited from HtmlControlDesigner) |
PostFilterAttributes(IDictionary) |
Allows a designer to change or remove items from the set of attributes that it exposes through a TypeDescriptor. (Inherited from ComponentDesigner) |
PostFilterEvents(IDictionary) |
Allows a designer to change or remove items from the set of events that it exposes through a TypeDescriptor. (Inherited from ComponentDesigner) |
PostFilterProperties(IDictionary) |
Allows a designer to change or remove items from the set of properties that it exposes through a TypeDescriptor. (Inherited from ComponentDesigner) |
PreFilterAttributes(IDictionary) |
Allows a designer to add to the set of attributes that it exposes through a TypeDescriptor. (Inherited from ComponentDesigner) |
PreFilterEvents(IDictionary) |
Sets the list of events that are exposed at design-time for the TypeDescriptor object for the component. (Inherited from HtmlControlDesigner) |
PreFilterProperties(IDictionary) |
Used by the designer to remove properties from or add properties to the display in the |
RaiseComponentChanged(MemberDescriptor, Object, Object) |
Notifies the IComponentChangeService that this component has been changed. (Inherited from ComponentDesigner) |
RaiseComponentChanging(MemberDescriptor) |
Notifies the IComponentChangeService that this component is about to be changed. (Inherited from ComponentDesigner) |
RaiseResizeEvent() |
Obsolete.
Raises the OnControlResize() event. (Inherited from ControlDesigner) |
RegisterClone(Object, Object) |
Registers internal data in a cloned control. (Inherited from ControlDesigner) |
SetEditableDesignerRegionContent(EditableDesignerRegion, String) |
Specifies content for an editable region of the design-time view of the associated control. |
SetRegionContent(EditableDesignerRegion, String) |
Specifies the content for an editable region in the design-time view of the control. (Inherited from ControlDesigner) |
SetViewFlags(ViewFlags, Boolean) |
Assigns the specified bitwise ViewFlags enumeration to the specified flag value. (Inherited from ControlDesigner) |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |
UpdateDesignTimeHtml() |
Refreshes the design-time HTML markup for the associated Web server control by calling the GetDesignTimeHtml method. (Inherited from ControlDesigner) |