--用户控件需要传递变量
<uc1:UserControl_2 id="UserControl_21"   type=<%=Type%>  runat=server></uc1:UserControl_2>
--CS代码:protected string Type="";
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
Type=Request.QueryString["Type"];
}此类问题如何解决?? 谢谢......

解决方案 »

  1.   

    服务器端控件要在后台代码中用Attributes集合给其加属性
    Attributes.Add("Type",Request.QueryString["Type"]);
      

  2.   

    我说的是客户端属性,如果是服务器端
    直接UserControl_21.属性 =
      

  3.   

    要在.cs代码中添加声明,类似:
    Protected UserControl_2 id UserControl_21;
      

  4.   

    将:
    <uc1:UserControl_2 id="UserControl_21"   type=<%=Type%>  runat=server></uc1:UserControl_2>
    改成:<uc1:UserControl_2 id="UserControl_21"   type="<%=Type%>" runat=server></uc1:UserControl_2>