Adding Code
Usually code will be added in the Render event -
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
...code...
End Sub |
Note here that we Override the Render event. You can also add the code in any one of the other events.
I will be looking at this in more detail later on.
Compiling
Compiling the custom control is as simple as running the following at the command prompt (or building it in VS.NET) -
vbc /t:library /r:System.dll,System.Web.dll CustomControlFileName.vb |
Displaying
As with a class library, you simply put the resulting DLL into the /bin directory of the target application and then register the tag on each page you want to use it on -
<%@ Register TagPrefix="MyPrefix" Namespace="AGASP" Assembly="AGASP" %> |
To register the control on the page. Then use the normal server/user control style to include it.
<MyPrefix:ctrl1 id="TestControl" runat="server" /> |
Note that the syntax is - TagPrefix:ClassName. This allows you to have multiple controls in one namespace (again making a reference to the Web Server Controls).