Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.net access a master page variable through content page

I have a master page:

<%@ Master Language="C#" AutoEventWireup="true" Codefile="AdminMaster.master.cs" Inherits="AlphaPackSite.MasterPages.AdminMaster" %>

Then I have a public variable:

public partial class AdminMaster : System.Web.UI.MasterPage
{
    protected bool blnShowDialogue = false;

In my content page I would like to set this variable:

blnShowDialogue = true;

So that in my master page I can have the code:

    $(function() {
    <%if(blnShowDialogue == true){%>
        $("#dialog").dialog();
    <% } %>
    }

Does this make sense? When I try combinations of Master.blnShowDialogue, or blnShowDialogue = , etc etc nothing seems to work.

The name 'blnShowDialogue' does not exist in the current context

like image 705
Tom Gullen Avatar asked Sep 06 '10 12:09

Tom Gullen


1 Answers

Use @MasterType directive, as explained here:

http://msdn.microsoft.com/en-us/library/c8y19k6h.aspx

like image 76
mamoo Avatar answered Nov 10 '22 00:11

mamoo