我写了一个自定义控件,而且这个自定义控件有ajax方法。然后我在aspx调用,我用这样的方法调用的
ASP.FriendList_UserCls test2;    protected void Page_Load(object sender, EventArgs e)
    {        test2 = (ASP.FriendList_UserCls)Page.LoadControl(Request.ApplicationPath + "/NewControls/FriendList_User.ascx");
        test2.labeltxt = "100004";
        test2.ClickEvent += this.test2_ClickEvent;
        this.PlaceHolder1.Controls.Add(test2);
    }
这样添加一个  是没有任何问题的  但是我再用这样的方法添加第二个的时候,就出问题了,好像是自定义控件的js  function(),只会执行一次,第二个添加的自定义控件根本不会执行了,请问这个怎么解决?Ajax自定义控件

解决方案 »

  1.   

    我知道问题的关键了,添加自定义控件的时候  相当于是把自定义控件的ascx的页面给复制到aspx页面   所以就出现了一个页面有多个名字相同的js函数,所以只执行的第一个。请问高手们有解决办法吗?
      

  2.   

                UserControl uc = new UserControl();
                string    sUserControl = Request.ApplicationPath + "/NewControls/FriendList_User.ascx"
                uc = Page.LoadControl(sUserControl) as UserControl;
                uc.ID = "UserControl1";//这里自己设置