本文整理匯總了C#中System.Web.UI.Design.SupportsPreviewControlAttribute類的典型用法代碼示例。如果您正苦於以下問題:C# SupportsPreviewControlAttribute類的具體用法?C# SupportsPreviewControlAttribute怎麽用?C# SupportsPreviewControlAttribute使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SupportsPreviewControlAttribute類屬於System.Web.UI.Design命名空間,在下文中一共展示了SupportsPreviewControlAttribute類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetDesignTimeHtml
//引入命名空間
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.Design.WebControls;
using System.Web.UI.WebControls;
using System.Reflection;
namespace ControlDesignerSamples.CS
{
// Define a simple designer associated with a
// simple text web control.
// Mark the designer with the SupportsPreviewControlAttribute set
// to true. This means the base.UsePreviewControl returns true,
// and base.ViewControl returns a temporary preview copy of the control.
[SupportsPreviewControl(true)]
public class SimpleTextControlDesigner : TextControlDesigner
{
// Override the base GetDesignTimeHtml method to display
// the design time text in italics.
public override string GetDesignTimeHtml()
{
string html = String.Empty;
try
{
// Initialize the return string to the default
// design time html of the base TextControlDesigner.
html = base.GetDesignTimeHtml();
// Get the ViewControl for the associated control.
Label ctrl = (Label)ViewControl;
ctrl.Style.Add(HtmlTextWriterStyle.FontStyle, "Italic");
html = base.GetDesignTimeHtml();
}
catch (System.Exception e)
{
if (String.IsNullOrEmpty(html))
{
html = GetErrorDesignTimeHtml(e);
}
}
return html;
}
}
// Derive a simple Web control from Label to render a text string.
// Associate this control with the SimpleTextControlDesigner.
[DesignerAttribute("ControlDesignerSamples.CS.SimpleTextControlDesigner"),
ToolboxData("<{0}:MyLabelControl Runat=\"Server\"><{0}:MyLabelControl>")]
public class MyLabelControl : Label
{
// Use the Label control implementation, but associate
// the derived class with the custom control designer.
}
}