看了微軟網站上面的簡單自定義控件的源代碼,可是做了半天也不出來.請問做自定義控件的步驟是?最好說詳細一些
下面是代碼:
Simple.aspx
<%@ Register TagPrefix="SimpleControlSamples" Namespace="SimpleControlSamples" Assembly="SimpleControlSamples" %>
<html>
<body>
<form method="POST" action="Simple.aspx" runat=server>
<SimpleControlSamples:Simple id="MyControl" runat=server/>
</form>
</body>
</html>
Simple.cs
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>");
}
}
}
希望高手指點,謝謝~!
下面是代碼:
Simple.aspx
<%@ Register TagPrefix="SimpleControlSamples" Namespace="SimpleControlSamples" Assembly="SimpleControlSamples" %>
<html>
<body>
<form method="POST" action="Simple.aspx" runat=server>
<SimpleControlSamples:Simple id="MyControl" runat=server/>
</form>
</body>
</html>
Simple.cs
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>");
}
}
}
希望高手指點,謝謝~!
Download source code for this book (646KB)
--5644_javascriptchapter.pdf
Download free extra chapter on creating controls that render JavaScript! (604Kb)
--5644_javascriptcode.zip
Download source code to accompany free chapter (150Kb)