1,将控件从工具箱拖到aspx设计视图,生成的代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ 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:FixedPositionDiv ID="FixedPositionDiv1" runat="server" HtmlContent="<b>内容测试</b>"
BorderColor="#009900" BorderStyle="Solid" Bottom="0px" Right="0px"
BorderWidth="2px" />
</form>
</body>
</html>
2,代码创建
protected void Page_Load(object sender, EventArgs e)
{
MengxianHui.WebUtil.WebControls.FixedPositionDiv fixedPositionDiv = new MengxianHui.WebUtil.WebControls.FixedPositionDiv();
fixedPositionDiv.HtmlContent = "<img src='http://dotnet.aspx.cc/Images/logoSite.gif'/>";
fixedPositionDiv.Width = 220;
fixedPositionDiv.Height = 60;
fixedPositionDiv.Position = MengxianHui.WebUtil.WebControls.FixedPositionDiv.MessagePosition.RightTop;
this.form1.Controls.Add(fixedPositionDiv);
}