public class TestDesigner : ControlDesigner
{
public override string GetPersistInnerHtml()
{
return text.ToString();
}
public override string GetDesignTimeHtml()
{
try
{
return “();
}
catch (Exception e)
{
return GetErrorDesignTimeHtml(e);
}
}
protected override string GetEmptyDesignTimeHtml()
{
//Render design time warning if there's nothing to display.
string text = "Please add Services to the toolbar.";
return CreatePlaceHolderDesignTimeHtml(text);
}
protected override string GetErrorDesignTimeHtml(Exception e)
{
string text = string.Format("{0}{1}{2}{3}",
"There was an error and the control can't be displayed.",
"<BR>", "Exception: ", e.Message);
return CreatePlaceHolderDesignTimeHtml(text);
}
}
[Designer(typeof(ScriptManagerDesigner))]
public class Test
{
}
这是一个关于自定义控件设计时支持的示例,实现了`ControlDesigner`类以提供设计时HTML。`GetPersistInnerHtml`返回控件的状态。`GetDesignTimeHtml`在捕获异常时调用`GetErrorDesignTimeHtml`显示错误信息,`GetEmptyDesignTimeHtml`则在没有内容显示时给出提示。
&spm=1001.2101.3001.5002&articleId=1575442&d=1&t=3&u=c6d5bc7cd2814876ac8676eeb5fae1cc)
1513

被折叠的 条评论
为什么被折叠?



