Disable button on main page .net 4.0 (C #)

I am trying to disable a button on the main page from the content page when certain criteria are met. I can change the text on the buttons of the main page using session variables, but IM has a bit of a problem with this last bit - any hints from anyone?

+5
source share
3 answers

On your main page, you will have a public function:

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

On the page of your content you should write:

((MyMasterType)this.Master).EnableTheButton(false);
+3
source

I would add a public method to your main page to do this, and let the content page call it. It can make things a lot easier and more objective.

MasterType , . .

<%@ MasterType virtualpath="~/Masters/Master1.master" %>
+3

, , "" . , , , . . .

-, . , , . Page-Master. ? -, .

, , . , , , .

? (, ), . , HttpContext.Items Session. , , . , - , (, ) . ( )

-, . , , , , .

, , , .

  • - - , -. . - , 6 , . - , , !

  • , . - (, if) . . , !:) - , , , , . , , .

masterdata:

public class MasterData
{
    private string _state1;

    public string State1
    {
        get { return _state1; }
        set
        {
            _state1 = value;
            OnDataChanged();
        }
    }

    private string _state2;

    public string State2
    {
        get { return _state2; }
        set
        {
            _state2 = value;
            OnDataChanged();
        }
    }

    public event EventHandler DataChanged;

    private void OnDataChanged()
    {
        if(this.DataChanged != null)
        {
            OnDataChanged(this, EventArgs.Empty);
        }
    }
}
+1
source

All Articles