Effect:
On the page where the control is placed: XML/html
CopyCode The Code is as follows: <% @ page Language = "C #" autoeventwireup = "true" codefile = "test6.aspx. cs" inherits = "test6" %>
<% @ Register tagprefix = "Custom" namespace = "mycomponents" %>
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> No title page </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Custom: mygrid runat = "server" id = "mygrid"/>
</Div>
</Form>
</Body>
</Html>
Put the control-related code in the app_code file and make comments. You can see the following:Copy codeThe Code is as follows: using system;
Using system. Web. UI;
namespace mycomponents
{< br> // system. web. UI. control all controls share this class. control development must inherit from Control
public class mygrid: Control
{< br> // override the render method of the control class, because all controls inherit from control, almost all controls have this method
// htmltextwriter class, the main task is to write the markup characters and text output
protected override void render (htmltextwriter writer)
{< br> writer. write ("
"); writer. write ("
| webmaster |
site |
"); writer. write ("
| ayunan |
sosuo8.com |
"); writer. write ("
");
base. render (writer);
// you can directly put the code in the app_code folder to automatically compile the code, you can also create a web control library
}< BR >}