您的位置:首页 > 其它

UserControls使用总结

2008-09-22 08:24 211 查看
1. 源文件型

WebUserControl.ascx

public AddressInfo Address

{

set

{

if (value != null)

{

if (!string.IsNullOrEmpty(value.Id))

id.Text = value.Id;

if (!string.IsNullOrEmpty(value.Name))

name.Text = value.Name;

}

}

}

<table border="0" cellpadding="0" cellspacing="0">

<tr>

<td>

<asp:Literal ID="id" runat="server"></asp:Literal>

<asp:Literal ID="name" runat="server"></asp:Literal><br/>

</td>

</tr>

</table>

Default.aspx

.html

<%@ Register src="UserControls/WebUserControl.ascx" tagname="ddd" tagprefix="uc1" %>

<uc1:ddd id="fff" runat="server"></uc1:ddd>

AddressInfo x = new AddressInfo("asdfa", "asdfa");

this.fff.Address = x;

2. 程序集形式:

<%@ Register assembly="myControls" namespace="myControls" tagprefix="cc1" %>

<cc1:RainbowLabel ID="RainbowLabel1" runat="server"></cc1:RainbowLabel>

this. RainbowLabel1.Address = x;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: