Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.Button'

I am getting this error: Unable to cast object of type ‘System.Web.UI.LiteralControl’ to type ‘System.Web.Controls.TextBox

foreach(Control x in this.Controls)
{
 Button btn = (Button)x;
 btn.Enabled = true;
}


#c-sharp #asp.net

6 Likes4.95 GEEK