aspx如何调用用户控件ascx?
目前遇到一个问题,在ascx中写好存储过程的参数调用。
aspx中左边是按钮,右边绑定左边按钮的选择响应数据。不太会。
请教各位高手。

解决方案 »

  1.   

    <%@ Register Src="~/Controls/ModelControl.ascx" TagName="ModelControl" TagPrefix="uc2" %>
    注册用户控件
    src 用户控件路径
    TagName 名称
    TagPrefix 空间调用
     <uc2:ModelControl ID="ModelControl1" runat="server" />
      

  2.   

    在用户控件中设置Public变量  然后在调用的页面 给变量赋值
      

  3.   

    LZ louti 的方法能具体点吗?谢谢
      

  4.   

     public void setType(int _recatagoryType)
        {
            recatagoryType = _recatagoryType;
           
            Resources(recatagoryType);
        }
    这是ascx.cs里面的代码。
    下面是aspx.cs里面的代码。如何响应bottun2事件。不会这个。急救。
        protected void Button2_Click(object sender, CommandEventArgs e)
        {
            
        }
      

  5.   

    Control a= LoadControl("a.ascx");  
    this.PlaceHolder1.Controls.Add(a);  
    委托实现
    用户控件中定义   
      public event EventHandler BtnEvent;   
      private void Btn_Click(object sender, System.EventArgs e)   
      {   
      if (BtnEvent != null)   
      {   
      BtnEvent(sender,e);   
      }   
      }   
        
      override protected void OnInit(EventArgs e)   
      {   
      btn.BtnEvent += new EventHander(this.test);   
      }   
      private void A(object sender ,System.EventArgs e)   
      {   
      }