Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

disable button on masterpage .net 4.0 (c#)

Im trying to disable a button on the masterpage from a content page when certain criteria are met. I can change the text on masterpage buttons using session variables, but IM having a bit of trouble with this latest bit - any hints anyone?

like image 760
DarkW1nter Avatar asked May 04 '11 16:05

DarkW1nter


People also ask

How master page and content page are connected?

The master page establishes a layout and includes one or more ContentPlaceHolder controls for replaceable text and controls. The content page includes only the text and controls that are merged at run time with the master page's ContentPlaceHolder controls.

On which page event we set the MasterPageFile property?

The Page class in the System. Web. UI namespace includes a MasterPageFile property that returns the path to the content page's master page; it is this property that is set by the @Page directive. This property can also be used to programmatically specify the content page's master page.


1 Answers

On your Master Page you would have a public function like so:

public void EnableTheButton(Boolean enable) {
  btnTheButton.Enabled = enable;
}

On your content page you would write:

((MyMasterType)this.Master).EnableTheButton(false);
like image 119
cusimar9 Avatar answered Sep 30 '22 08:09

cusimar9