ASP.net通过内容页访问母版页变量 [英] ASP.net access a master page variable through content page

查看:435
本文介绍了ASP.net通过内容页访问母版页变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个母版页:

 <%@主语言=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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆