Here my code :

protected override void OnPreInit(EventArgs e)
 
  {
 
     
 

base.OnPreInit(e);
 
     
 

switch (Session["role"].ToString())
 
      {
 
         
 

case "X":
 
              MasterPageFile =
 

"X.Master";
 
             
 

break;
 
         
 

case "SS":
 
              MasterPageFile =
 

"SS.Master";
 
             
 

break;
 
 
 
default:
 
              MasterPageFile =
 

"XS.Master";
 
             
 

break;
 
      }
 
    
 

if (Session["role"].ToString() == "SS")
 
      
 
         {     btnSearch.Enabled =
 

true;
 
                rbSerial.Checked =
 

false;
 
                rbName.Checked =
 

false;
 
             }
 
        
 

else 

           {
 
               btnSearch.Enabled =
 

false;
 
           
 
             }
 
            
 
      }
 
 ..
 
please advice

Hmmm I am not too sure when the event OnPreInit fires but I suspect it is prior to any control init code (hence, on preinitialization). Try putting the code in a different event that fires on load, but after the control initialization (such as OnLoad or something similar). Bascially your .Enabled values are being overwritten by the initialization properties (the ones you set in the IDE)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.