Page 57 - DCAP312_WEB_TECHNOLOGIES_II
P. 57

Unit 3: Server Controls Basic



            The full name of the child button will be Control1$Trigger. Suppose we click on the button and   Notes
            cause the page to post back. If the name of the posting control contains the $ symbol, the ASP.
            NET runtime recognizes a known pattern: tokenize the name and locate the postback control
            correctly, no matter its depth in the page tree.
                          If the button is contained in a control not marked to be a naming container,
                          the ID of the clicked button is not prefixed and will simply be, say, Trigger.
                          In this case, the ASP.NET runtime will look for it as a direct child of the form.
                          The search will obviously fail the button is a child of a top-level control and
                          the postback event will pass unnoticed.

            3.3.4 Themeable Controls
            In the ASP.NET terminology, a theme is a named compilation of possessions settings that can
            be applied to wheel to make them look steady across pages. We can apply theme setting to an
            entire Web site, to a page and its controls, or to an individual control. A theme is identified by
            name and consists of cascading style sheet (CSS) files, images, and control skins. A control skin
            is a text file that contains predefined values for some control properties. Applied together, these
            settings contribute to change the look and feel of the control and give the whole site a consistent
            (and, we hope, appealing) user interface. In addition, because themes are a sort of monolithic
            attribute, we can easily export that look from one application to the next. With themes enabled,
            if the developer adds, say, a Data Grid control to a page, the control is rendered with the default
            appearance defined in the currently selected theme. Server controls can dynamically accept or
            deny theming through a Boolean property named Enable Heming, set to true by default. As a
            general rule, themes affect only properties that relate to the control’s appearance. Properties that
            explicitly specify behaviour or imply an action should not be made themeable. Each control has
            the power to state which properties are themeable and which are not. This happens at compile
            time through attributes – in particular, the Themeable attribute.

            3.3.5 Control State
            Some ASP.NET controls need that several states are kept crossways needs. Examples of this type
            of state information include the present page of a paged control and the present sort order of a
            sort able data manage. In ASP.NET 1.x, there is only one storage place in which this data can
            be stored the view state. However, the view state is mainly designed to maintain settings set
            by the application and, more importantly, it can be turned off. What would happen to control
            specific state in this case? For this reason, starting with ASP.NET 2.0 Microsoft introduced the
            notion of the “control state” and managed to keep it separate from the view state. So it is clear
            that control state is a vital piece of the control infrastructure.

            Control state is a collection of critical view state data that controls need to function. Because of
            its critical role, control state data is contained in separate member variables from normal view
            state and is not affected when view state is disabled. Unlike view state, control state requires
            extra implementation steps to use.

            For one thing, each control needs to signal to the page that it requires control state. Next, there
            is no unique container to store data, such as View State; but the data can be retrieved from any
            object we want – arrays, collections, or a slew of instance variables. Each control persists and
            loads its control state using a pair of overridable methods, as shown here:

            Protected override object SaveControlState ()
            Protected override void LoadControlState (object state)
            Control state works similarly to view state and is saved and loaded at the same stage of the
            Pipeline that view state is processed. Ultimately, control state is persisted in the same hidden
            field as the view state.


                                             LOVELY PROFESSIONAL UNIVERSITY                                    51
   52   53   54   55   56   57   58   59   60   61   62