asp.net ajax Advance Tips & Tricks (8) extending controls in the AJAX Control Toolkit

Source: Internet
Author: User
Tags bool

Demand:

The TabPanel class in the Tabcontainer container itself contains the Enabled property, or you can use the JavaScript method set_enabled (X) to set the Enabled property, if this property of a TabPanel is false , this tabpanel will not be shown in Tabcontainer, which is not quite the same as the "Enabled" property of a generic control, and I think it would be more appropriate to call it "visiable". As shown in the following illustration:

Sometimes this doesn't fit our needs, so in this case, we'll add the disabled feature so that the TabPanel control can turn gray without responding to client events.

1. Add service-side properties:

First we find the TabPanel.cs, which is the TabPanel class, in which you add the following attribute to represent whether the TabPanel is either "restore Enabled" or "dimmed disabled" status:

        [DefaultValue("")]
        [Category("Behavior")]
        [ExtenderControlProperty]
        [ClientPropertyName("disabled")]
        public bool Disabled 
        {
            get { return (bool)(ViewState["Disabled"] ?? false); }
            set { ViewState["Disabled"] = value; }
        }

        internal bool Active
        {
            get { return _active; }
            set { _active = value; }
        }

In the attribute, we set Clientpropertyname to "disabled", which is to map this property to the _disabled attribute in the JavaScript behavior code and save the container in ViewState state.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.