.net关于如何给用户控件传值问题解决

网页前台:中间插入用户控件,需注册自定义控件

...

<uc1:test ID="test1" runat="server" ShowTitle="您想要传值的值"/>

...

用户控件前台:

<asp:Label ID="lblShowTitile" runat="server" Text="关键词:"></asp:Label>

<asp:TextBox ID="txtKeywords" runat="server"></asp:TextBox>

<asp:Button ID="btnSearch" runat="server" Text="搜索" />


用户控件后台:

public partial class UserControl_test : System.Web.UI.UserControl

{

    protected void Page_Load(object sender, EventArgs e)

    {

    }

    public string ShowTitle

    {

        get

        {

            return lblShowTitile.Text;

        }

        set

        {

            lblShowTitile.Text = value;

        }

    }

}


posted @ 2013-10-10 13:18  武二郎  阅读(343)  评论(0编辑  收藏  举报