zoukankan      html  css  js  c++  java
  • 关于用户控件的几点说明

    Register Src="../UserControl/UserTopLow.ascx" TagName="UserTopLow" TagPrefix="uc2"

    TagPrefix表示一类,这个在引用多个用户控件的时候可以一样,就表示是一类

    TagName表示具体的某一个控件,唯一标示

    Src表示地址

    在自定义控件不提供自己的属性的情况下,可以直接在后台通过

    UserControl Menu = LoadControl("../UserControl/LowMenu.ascx") as UserControl;
                    PlaceHolder1.Controls.Add(Menu);

    来引用控件,这种情况不需要在前台页面引用具体的控件地址(Register Src="../UserControl/UserTopLow.ascx" TagName="UserTopLow" TagPrefix="uc2")

    在自定义控件提供了自己的属性的情况下,首先,在前台页面就必须引入控件地址如:

    <%@ Register Src="../UserControl/LowMenu.ascx" TagName="MyMenu" TagPrefix="uc2" %>,注意,此处必须线引入控件是为了后台使用控件里面的类,然后在后台操作,如下

    UserControl_LowMenu SunMenu = (UserControl_LowMenu)Page.Load("../UserControl/LowMenu.ascx");
    SunMenu.MyType

    UserControl_LowMenu 为LowMenu.ascx控件的类名,MyType为自定义属性,可如下操作

    private int _BigClass;
        private int _SmallClass;

        public int BigClassId
        {
            get
            {
                return _BigClass;
            }
            set
            {
                _BigClass=value;
            }
        }

        public int SmallClassId
        {
            get
            {
                return _SmallClass;
            }
            set
            {
                _SmallClass=value;
            }
        }

        protected int i = 1;
        Product_Class S_Class = new Product_Class();

        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            //{
                Repeater1.DataSource = S_Class.GetClass(SmallClassId);
                Repeater1.DataBind();
            //}
        }

  • 相关阅读:
    字典树模板
    hdu 1013 Digital Roots(数论 模拟)
    linux shell输出带颜色文本
    homebrew update 出现Failure while executing: git pull --quiet origin refs/heads/master:refs/remotes/origin/master解决方案
    macosx 10.11 python pip install 出现错误OSError: [Errno 1] Operation not permitted:
    Leetcode Palindrome Linked List
    Leetcode Delete Node in a Linked List
    Leetcode Valid Anagram
    Leetcode Kth Smallest Element in a BST
    Leetcode Power of Two
  • 原文地址:https://www.cnblogs.com/hateyoucode/p/1571014.html
Copyright © 2011-2022 走看看