1. Add the ToolboxData attribute to the server control.
Using System;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Using System. ComponentModel;
Namespace WebControlLibrary1
{
[ToolboxData ("<{0}: WebCustomControl runat = server> </{0}: WebCustomControl>")]
Public class WebCustomControl: System. Web. UI. WebControls. WebControl
{
}
}
The WebCustomControl in ToolboxData is the name of the server control class.
2. Add the following information to the Assembly. cs file of the server control:
Using System. Web. UI
[Assembly: TagPrefix ("WebControlLibrary1", "mycontrol")]
The TagPrefix attribute is located under the System. Web. UI naming control. Therefore, you must reference the System, Web. UI namespace
The prototype of TagPrefix is [assembly: TagPrefix ("namespace", "tagprefix")].
The generated control is dragged to the page to generate the code.
<Mycontrol: WebCustomControl1 runat = "server"> </mycontrol>