ASP.net通过内容页访问母版页变量 [英] ASP.net access a master page variable through content page
问题描述
我有一个母版页:
<%@主语言=C#AutoEventWireup =真$ C $的CFile =AdminMaster.master.cs继承=AlphaPackSite.MasterPages.AdminMaster%GT ;
然后,我有一个公共变量:
公共部分类AdminMaster:System.Web.UI.MasterPage
{
保护布尔blnShowDialogue = FALSE;
在我的内容页的我想设置这个变量:
blnShowDialogue = TRUE;
所以,在我的母版页,我可以有code:
$(函数(){
<%,如果(blnShowDialogue ==真){%GT;
$(#对话)对话()。
<%}%GT;
}
这是否有道理?当我尝试blnShowDialogue = Master.blnShowDialogue的组合,或者,等等等等似乎没有任何工作。
blnShowDialogue'名称不
存在于当前上下文
块引用>解决方案使用@MasterType指令,如下解释:
<一个href=\"http://msdn.microsoft.com/en-us/library/c8y19k6h.aspx\">http://msdn.microsoft.com/en-us/library/c8y19k6h.aspx
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
解决方案Use @MasterType directive, as explained here:
http://msdn.microsoft.com/en-us/library/c8y19k6h.aspx
这篇关于ASP.net通过内容页访问母版页变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!