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">
<ifc:CtrlClass ID="id1" runat="server" Text='<%# Eval "BoundCol1") %>' />

"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 ...