I would like to set the a property value on a user control. It sounds easy enough. First, I would like to create a web control then I would like to access one of its properties "HasAccess" and set the value to "true".

In this example we are assuming that the web control is been called from a master page and the property that needs to be set is from a web page. In the web page we need to first find the user control and then set its property.

   1: if (Master != null)
   2: {
   3:     Control ctlMyControl = Master.FindControl("ctlMyControl") as Control;
   4:     if (ctlMyControl != null)
   5:     {
   6:         Type ucType = null;
   7:         ucType = ctlMyControl .GetType();
   8:  
   9:         PropertyInfo hasAccess = ucType.GetProperty("HasAccess");
  10:  
  11:         // Only set the first control as each on page will pass through code. 
  12:         if (hasAccess.GetValue(ctlMyControl , null) == null)
  13:             hasAccess.SetValue(ctlMyControl , True, null);
  14:     }
  15: }