您的位置:首页 > 其它

定义用户控件属性,用户控件值的传递

2005-03-18 11:26 375 查看
新建一个用户控件,并创建控件公共属性。WebUserControl.ascx

<asp:DropDownList id="D1" runat="server">

    <asp:ListItem Value="0">-请选择-</asp:ListItem>

    <asp:ListItem Value="ok1">222</asp:ListItem>

    <asp:ListItem Value="ok2">333</asp:ListItem>

    <asp:ListItem Value="444">444</asp:ListItem>

    <asp:ListItem Value="555">555</asp:ListItem>

</asp:DropDownList>

WebUserControl.ascx.vb

在页面上引用用户控件,取得属性值并将取得的属性值显示于文本框中:uc.aspx

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>

    <HEAD>

        <title>uc</title>

        <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">

        <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">

        <meta content="JavaScript" name="vs_defaultClientScript">

        <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">

    </HEAD>

    <body MS_POSITIONING="GridLayout">

        <form id="Form1" method="post" runat="server">

            <asp:button id="Button1" style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 128px" runat="server"

                Text="Button"></asp:button>

            <asp:TextBox id="T1" style="Z-INDEX: 102; LEFT: 16px; POSITION: absolute; TOP: 72px" runat="server"></asp:TextBox>

            <uc1:WebUserControl id="Uc1" runat="server"></uc1:WebUserControl></form>

    </body>

</HTML>

uc.aspx.vb
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐