本文整理汇总了C#中System.Web.UI.Design.ControlDesigner.ViewControl属性的典型用法代码示例。如果您正苦于以下问题:C# ControlDesigner.ViewControl属性的具体用法?C# ControlDesigner.ViewControl怎么用?C# ControlDesigner.ViewControl使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Web.UI.Design.ControlDesigner
的用法示例。
在下文中一共展示了ControlDesigner.ViewControl属性的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.
}
}