1,将控件从工具箱拖到aspx设计视图,生成的代码如下:
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Register Assembly="MengxianHui.WebControls" Namespace="MengxianHui.WebUtil.WebControls"
TagPrefix="mxh" %>
<!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></title>
</head>
<body>
<form runat="server" id="form1">
<mxh:FloatContent ID="FloatContent1" runat="server"
HtmlContent="<a href="http://dotnet.aspx.cc/"><img src="http://dotnet.aspx.cc/Images/logoSite.gif" border="0" /></a>">
</mxh:FloatContent>
</form>
</body>
</html>
2,代码创建
protected void Page_Load(object sender, EventArgs e)
{
MengxianHui.WebUtil.WebControls.FloatContent floatContent = new MengxianHui.WebUtil.WebControls.FloatContent();
floatContent.HtmlContent = "<a href='http://dotnet.aspx.cc/'><img src='http://dotnet.aspx.cc/Images/logoSite.gif' border='0' /></a>";
this.form1.Controls.Add(floatContent);
}