Tuesday, April 27, 2010

Include a derived control in my aspx page

register control at top of page giving it a TagPrefix:


<%@ Register Assembly="iProjectName" Namespace="iNamespceInCsFile" TagPrefix="ifc" %>



use tag prefix and control name in aspx


<ig:TemplateDataField Key="key1" Width="30px">
<ItemTemplate>
<ifc:CtrlClass ID="id1" runat="server" Text='<%# Eval "BoundCol1") %>' />
</ItemTemplate>
</ig:TemplateDataField>



"CtrlClass" is the derived control class name, which is in a cs file name doesn't matter, but namespace is "iNamespceInCsFile" in project ="iProjectName".

public class Comment2 : TextBox
{ etc ...