Friday, September 2, 2011

Access the Parent class controlers thruogh the User Controles

I had a problem when I used User Controller in my first time. Problem was how to access the parent class items through the User Controller. Our project Tech Lead, Nalaka ayya gave me a good solution to it. Solution was access the controls through the interface. In this post I tried to share that solution with you.  

1. Create the interface

2. Create the User Controller (WebUserControl). In user controller I add two button field, those button used to change the  visibility of label in Default.aspx class

Button commands call to DoJob method.

This DoJob method call to the Interface and pass the value

3. I used User Controller (WebUserControl) in Default.aspx page       

In Default.aspx code behind class I implement the Interface (IControler)

4. According to the command this can control the visibility of the lable (lblName)

I create Code class and add Enum (Commands) to save to constant value.(Optional)

No comments:

Post a Comment