当前位置:编程学习 > C#/ASP.NET >>

用户控件不显示

--------------------编程问答-------------------- 原来是我把它放在Panel控件里了!
<asp:Panel ID="pnlLeftCategoryList" runat="server" BorderWidth="1px" Height="200px"
                Width="200px">
            <asp:TreeView ID="treeLeftCategoryList" runat="server" ShowCheckBoxes="Leaf" ShowLines="True">
            </asp:TreeView>
</asp:Panel>

不过现在访问this.treeLeftCategoryList却为null --------------------编程问答-------------------- 问题原因找到了,原来是为了在aspx页中访问用户控件中的TreeView控件,我将其作为属性暴露出来
/// <summary>
        /// 左边的树型控件
        /// </summary>
        public TreeView LeftTreeView
        {
            get { return treeLeftCategoryList; }
        }

        /// <summary>
        /// 右边的树型控件
        /// </summary>
        public TreeView RightTreeView
        {
            get { return treeRightCategoryList; }
        }

结果在访问的时候,LeftTreeView和treeLeftCategoryList都为null,后来通过其FindControl方法,改为(TreeView)(this.ExchangeTreeView1.FindControl("treeRightCategoryList"))访问就好了。 --------------------编程问答--------------------

LZ你又是何苦类。。。自己给抢答 了 --------------------编程问答-------------------- 呵呵……
补充:.NET技术 ,  组件/控件开发
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,