分享

用户控件赋值

 悟静 2012-09-22

问题来自http://topic.csdn.net/u/20120226/15/09b1fd42-b587-483b-b4df-9cba2ef3d0ad.html 也可参考下图:

 

Insus.NET提供如下解决方法,仅供参考:

写一个接口,

复制代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for ISetable
/// </summary>
namespace Insus.NET
{
    public interface ISetable
    {
        void SetTextBoxText(string value);
    }
}
复制代码

 

用户控件实作这个接口,

复制代码
using Insus.NET;

public partial class WebUserControl : System.Web.UI.UserControl,ISetable
{
    public void SetTextBoxText(string value)
    {
        this.text2.Text = value;
    }
}
复制代码

 

然后在page的Button的Click事件中写,

 protected void Button1_Click(object sender, EventArgs e)
    {
        ISetable set = (ISetable)this.WebUserControl1;
        set.SetTextBoxText(this.text1.Text);
    }

 

测试:

 

测试代码:

 http://download.cnblogs.com/insus/ASPDOTNET/SetUserControlTextboxText.rar

 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多