UserControls使用总结

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;

posted @ 2008-09-22 08:24  Shapley  阅读(384)  评论(0编辑  收藏  举报