Hi James,
To create a simple custom Label with a custom desiger, here is a simple
example:
I override the three methods that will return the design-time html of the
webcontrol(display a placeholder char--#)
====================================
[Designer(typeof(SimpleLabelDesigner), typeof(IDesigner))]
[ToolboxData("<{0}:SimpleLabel runat=server></{0}:SimpleLabel>")]
public class SimpleLabel : Label
{
}
public class SimpleLabelDesigner : ControlDesigner
{
public override string GetDesignTimeHtml()
{
return "#";
}
public override string GetDesignTimeHtml(DesignerRegionCollection
regions)
{
return "#";
}
protected override string GetEmptyDesignTimeHtml()
{
return "#";
}
}
====================================
However, I found that for template databound control (Like Gridview,
repeater or FormView), the design-time html is not controled by control
itself , but controled by the template databound control. If you put the
following control item into different template databond
control(ItemTemplate), the design-time text is also different:
<asp:Label ID="CategoryIDLabel1" runat="server" Text='<%#
Eval("CategoryID") %>'>
Anyway, please feel free to let me know if there is any other information
you wonder.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
|