DataListDesigner 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
擴充了網頁伺服器控制的設計時行為 DataList 。
public ref class DataListDesigner : System::Web::UI::Design::WebControls::BaseDataListDesigner
public class DataListDesigner : System.Web.UI.Design.WebControls.BaseDataListDesigner
[System.Web.UI.Design.SupportsPreviewControl(true)]
public class DataListDesigner : System.Web.UI.Design.WebControls.BaseDataListDesigner
type DataListDesigner = class
inherit BaseDataListDesigner
[<System.Web.UI.Design.SupportsPreviewControl(true)>]
type DataListDesigner = class
inherit BaseDataListDesigner
Public Class DataListDesigner
Inherits BaseDataListDesigner
- 繼承
- 屬性
範例
以下程式碼範例示範如何擴充該 DataListDesigner 類別。 若啟用控制項,程式碼會 GetDesignTimeHtml 覆寫顯示紫色五點邊框 DataList 的方法。
using System;
using System.Drawing;
using System.Security.Permissions;
using System.ComponentModel;
using System.Web.UI.WebControls;
using System.Web.UI.Design;
using System.Web.UI.Design.WebControls;
namespace ASPNET.Examples.CS
{
[SecurityPermission(
SecurityAction.Demand,
Flags = SecurityPermissionFlag.UnmanagedCode)]
public class SimpleGridViewDesigner : GridViewDesigner
{
private SimpleGridView simpleGView;
public override string GetDesignTimeHtml()
{
string designTimeHtml = String.Empty;
simpleGView = (SimpleGridView)Component;
// Check the control's BorderStyle property to
// conditionally render design-time HTML.
if (simpleGView.BorderStyle == BorderStyle.NotSet)
{
// Save the current property settings in variables.
int oldCellPadding = simpleGView.CellPadding;
Unit oldBorderWidth = simpleGView.BorderWidth;
Color oldBorderColor = simpleGView.BorderColor;
// Set properties and generate the design-time HTML.
try
{
simpleGView.Caption = "SimpleGridView";
simpleGView.CellPadding = 1;
simpleGView.BorderWidth = Unit.Pixel(3);
simpleGView.BorderColor = Color.Red;
designTimeHtml = base.GetDesignTimeHtml();
}
catch (Exception ex)
{
// Get HTML from the GetErrorDesignTimeHtml
// method if an exception occurs.
designTimeHtml = GetErrorDesignTimeHtml(ex);
// Return the properties to their original values.
}
finally
{
simpleGView.CellPadding = oldCellPadding;
simpleGView.BorderWidth = oldBorderWidth;
simpleGView.BorderColor = oldBorderColor;
}
}
else
{
designTimeHtml = base.GetDesignTimeHtml();
}
return designTimeHtml;
}
protected override string
GetErrorDesignTimeHtml(System.Exception exc)
{
return CreatePlaceHolderDesignTimeHtml(
"ASPNET.Examples: An error occurred while rendering the GridView.");
}
public override void Initialize(IComponent component)
{
simpleGView = (SimpleGridView)component;
base.Initialize(component);
}
}
}
Imports System.Drawing
Imports System.ComponentModel
Imports System.Web.UI.WebControls
Imports System.Security
Imports System.Web.UI.Design
Imports System.Web.UI.Design.WebControls
Namespace ASPNET.Examples
< _
Designer("ASPNET.Examples.Design.SimpleGridViewDesigner", _
"System.Web.UI.Design.GridViewDesigner") _
> _
Public Class SimpleGridView
Inherits GridView
' Code to customize your GridView goes here
End Class
End Namespace
Namespace ASPNET.Examples.Design
<Permissions.SecurityPermission( _
Permissions.SecurityAction.Demand, _
Flags:=Permissions.SecurityPermissionFlag.UnmanagedCode)> _
Public Class SimpleGridViewDesigner
Inherits GridViewDesigner
Private simpleGView As SimpleGridView
Public Overrides Function GetDesignTimeHtml() As String
Dim designTimeHtml As String = String.Empty
simpleGView = CType(Component, SimpleGridView)
' Check the control's BorderStyle property to
' conditionally render design-time HTML.
If (simpleGView.BorderStyle = BorderStyle.NotSet) Then
' Save the current property settings in variables.
Dim oldCellPadding As Integer = simpleGView.CellPadding
Dim oldBorderWidth As Unit = simpleGView.BorderWidth
Dim oldBorderColor As Color = simpleGView.BorderColor
' Set properties and generate the design-time HTML.
Try
simpleGView.Caption = "SimpleGridView"
simpleGView.CellPadding = 1
simpleGView.BorderWidth = Unit.Pixel(3)
simpleGView.BorderColor = Color.Red
designTimeHtml = MyBase.GetDesignTimeHtml()
Catch ex As Exception
' Get HTML from the GetErrorDesignTimeHtml
' method if an exception occurs.
designTimeHtml = GetErrorDesignTimeHtml(ex)
' Return the properties to their original values.
Finally
simpleGView.CellPadding = oldCellPadding
simpleGView.BorderWidth = oldBorderWidth
simpleGView.BorderColor = oldBorderColor
End Try
Else
designTimeHtml = MyBase.GetDesignTimeHtml()
End If
Return designTimeHtml
End Function
Protected Overrides Function _
GetErrorDesignTimeHtml(ByVal exc As Exception) As String
Return CreatePlaceHolderDesignTimeHtml( _
"ASPNET.Examples: An error occurred while rendering the GridView.")
End Function
Public Overrides Sub Initialize(ByVal component As IComponent)
simpleGView = CType(component, SimpleGridView)
MyBase.Initialize(component)
End Sub
End Class
End Namespace
以下程式碼範例展示了如何利用 將 DesignerAttribute 設計者與 DataList 控制項關聯起來。
[ Designer("ASPNET.Examples.Design.SimpleGridViewDesigner",
"System.Web.UI.Design.GridViewDesigner")]
public class SimpleGridView : GridView
{
// Code to customize your GridView goes here
}
< _
Designer("ASPNET.Examples.Design.SimpleGridViewDesigner", _
"System.Web.UI.Design.GridViewDesigner") _
> _
Public Class SimpleGridView
Inherits GridView
' Code to customize your GridView goes here
End Class
建構函式
| 名稱 | Description |
|---|---|
| DataListDesigner() |
初始化 DataListDesigner 類別的新執行個體。 |
屬性
| 名稱 | Description |
|---|---|
| ActionLists |
為此設計師取得設計師行動清單系列。 (繼承來源 BaseDataListDesigner) |
| ActiveTemplateEditingFrame |
已淘汰.
取得活躍的模板編輯框架。 (繼承來源 TemplatedControlDesigner) |
| AllowResize |
會得到一個值,表示控制項是否 DataList 可以調整大小。 |
| AssociatedComponents |
取得設計師管理的與該元件相關的元件集合。 (繼承來源 ComponentDesigner) |
| AutoFormats |
取得 DesignerAutoFormatCollection 與此設計者相關的物件。 |
| Behavior |
已淘汰.
取得或設定與設計器相關的 DHTML 行為。 (繼承來源 HtmlControlDesigner) |
| CanEnterTemplateMode |
會有一個值,表示該設計師是否允許查看或編輯範本。 (繼承來源 TemplatedControlDesigner) |
| Component |
取得設計師正在設計的元件。 (繼承來源 ComponentDesigner) |
| DataBindings |
取得目前控制項的資料綁定收集。 (繼承來源 HtmlControlDesigner) |
| DataBindingsEnabled |
會得到一個值,表示設計者是否允許資料綁定。 (繼承來源 TemplatedControlDesigner) |
| DataKeyField |
取得或設定相關控制項資料鍵欄位的值。 (繼承來源 BaseDataListDesigner) |
| DataMember |
取得或設定相關控制項資料成員欄位的值。 (繼承來源 BaseDataListDesigner) |
| DataSource |
取得或設定相關控制項資料來源屬性的值。 (繼承來源 BaseDataListDesigner) |
| DataSourceDesigner |
當選擇資料綁定時,取得資料來源的設計者。 (繼承來源 BaseDataListDesigner) |
| DataSourceID |
取得或設定設計者版本的資料來源 ID 屬性,並用來追蹤相關控制項的相應屬性。 (繼承來源 BaseDataListDesigner) |
| DesignerState |
取得一個物件,用於在設計時持久化相關控制項的資料。 (繼承來源 ControlDesigner) |
| DesignerView |
取得綁定到相關控制項的資料來源預設視圖。 (繼承來源 BaseDataListDesigner) |
| DesignTimeElement |
已淘汰.
取得代表該物件在設計表面上所關聯 HtmlControlDesigner 控制項的設計時物件。 (繼承來源 HtmlControlDesigner) |
| DesignTimeElementView |
已淘汰.
取得控制設計器的視控物件。 (繼承來源 ControlDesigner) |
| DesignTimeHtmlRequiresLoadComplete |
會取得一個值,指示是否必須完成載入才能顯示設計時標記。 (繼承來源 BaseDataListDesigner) |
| Expressions |
在設計時取得目前控制項的表達式綁定。 (繼承來源 HtmlControlDesigner) |
| HidePropertiesInTemplateMode |
會取得一個值,表示當控制項進入範本編輯模式時,控制項的屬性是否會被隱藏。 (繼承來源 TemplatedControlDesigner) |
| ID |
取得或設定控制項的 ID 字串。 (繼承來源 ControlDesigner) |
| InheritanceAttribute |
會獲得一個屬性,表示相關元件繼承的類型。 (繼承來源 ComponentDesigner) |
| Inherited |
會得到一個值,表示該元件是否為繼承。 (繼承來源 ComponentDesigner) |
| InTemplateMode |
已淘汰.
會取得一個值,表示設計器文件是否處於範本模式。 (繼承來源 TemplatedControlDesigner) |
| IsDirty |
已淘汰.
取得或設定一個值,表示網頁伺服器控制項是否被標記為變更。 (繼承來源 ControlDesigner) |
| ParentComponent |
取得這個設計器的父元件。 (繼承來源 ComponentDesigner) |
| ReadOnly |
已淘汰.
取得或設定一個值,表示控制項屬性在設計時是否為唯讀。 (繼承來源 ControlDesigner) |
| RootDesigner |
取得包含相關控制項的網頁表單頁面的控制項設計器。 (繼承來源 ControlDesigner) |
| ShadowProperties |
會取得一組屬性值,覆蓋使用者設定。 (繼承來源 ComponentDesigner) |
| ShouldCodeSerialize |
已淘汰.
在序列化過程中,會取得或設定一個值,指示是否要在目前設計文件的程式碼背後檔案中為控制項建立欄位宣告。 (繼承來源 HtmlControlDesigner) |
| Tag |
取得一個代表相關控制項 HTML 標記元素的物件。 (繼承來源 ControlDesigner) |
| TemplateGroups |
會得到一組模板群組,每個群組都包含一個範本定義。 (繼承來源 TemplatedControlDesigner) |
| TemplatesExist |
會取得一個值,表示是否為相關控制定義了範本。 |
| UsePreviewControl |
會取得一個值,指示控制項設計者是否使用暫存預覽控制來產生設計時的 HTML 標記。 (繼承來源 ControlDesigner) |
| Verbs |
取得這個設計師可用的動詞集合。 (繼承來源 BaseDataListDesigner) |
| ViewControl |
取得或設定一個網頁伺服器控制項,可用於預覽設計時的 HTML 標記。 (繼承來源 ControlDesigner) |
| ViewControlCreated |
取得或設定一個值,指示是否 |
| Visible |
會獲得一個值,表示該控制點在設計時是否可見。 (繼承來源 ControlDesigner) |