Skip to Content

It just came to my attention that code written as the content of a TabStrip control (TabContent) might be required to be used outside of the context of the TabStrip control.

A possible scenario would be a portal component developed to be used by two roles – a manager and an employee. Lets assume this application is an expense reimbursement application.

The manager will have two views – one as a user of the application who can enter data and submit a request for reimbursement and another view in which he can approve or decline a request made by an employee of his.

The screen for the manager can be implemented by using a TabStrip control with the two views stated above.

For the employee however, there will be only one view – the reimbursement request so there is no reason to use a TabStrip control as he has only one view. As the developers of the application we would like to avoid reimplemeting the reimbursement view, one time as TabContent and one time as PortalComponent.

In order to avoid this code rewriting, we can use the following code:

        // This is the Page_Load method of the employee view.
        protected void Page_Load(object sender, EventArgs e)
        {
            // 'ReimbusementRequest.ascx' is implemented as TabContent.
            // Load it and add it to the portal component's control collection.
            // Now it will show independent of the TabStrip control.
            Control c = this.LoadControl("ReimbusementRequest.ascx");
            this.Controls.Add(c);
        }

The code above loads the TabContent ascx file and places it as a control in the portal component. By using this tecnique code rewriting is avoided.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply