wulixuan

导航

自定义控件学习(1)

<%@ Register TagPrefix="SimpleControlSamples" Namespace="SimpleControlSamples" Assembly="1" %>
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="_1.WebForm1" %>
<HTML>
    
<body>
        
<form id="Form1" action="WebForm1.aspx" method="post" runat="server">
            
<SIMPLECONTROLSAMPLES:SIMPLE id="MyControl" runat="server"></SIMPLECONTROLSAMPLES:SIMPLE></form>
    
</body>
</HTML>

    
using System;
    
using System.Web;
    
using System.Web.UI;

    
namespace SimpleControlSamples 
    
{

        
public class Simple : Control 
        
{

            
protected override void Render(HtmlTextWriter output) 
            
{
                output.Write(
"<H2>欢迎使用控件开发!</H2>");
            }

        }
    
    }


 
其中:Assembly="1" 必须是你所建的工程名. Namespace 是你的一个命名空间.SimpleControlSamples:是你注册名 simple 是一个类名.

posted on 2006-04-02 11:14  零点时刻  阅读(317)  评论(0编辑  收藏  举报