How to determine which Child Page is being displayed from Master Page?

前端 未结 16 725
一生所求
一生所求 2021-02-02 10:26

I\'m writing code on the master page, and I need to know which child (content) page is being displayed. How can I do this programmatically?

16条回答
  •  时光取名叫无心
    2021-02-02 10:52

    I have had a reason to check the child page in the master page.

    I have all my menu options on my master page and they need to be disabled if certain system settings are not set up.

    If they are not then a message is displayed and the buttons are disabled. As the settings page is a content page from this master page I don't want the message to keep being displayed on all the settings pages.

    this code worked for me:

                    //Only show the message if on the dashboard (first page after login)
                    if (this.ContentPlaceHolder1.Page is Dashboard)
                    {
                        //Show modal message box
                        mmb.Show("Warning Message");
                    }
    

提交回复
热议问题