禁用ScriptManager的某些网页 [英] Disable ScriptManager on certain pages

查看:103
本文介绍了禁用ScriptManager的某些网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的主网页上的脚本经理。有迹象表明,我需要删除从webresourse.axd一间或两页的内容,因为它导致网页

I have a script manager on my Master page. There are one or 2 content pages that I need to remove the webresourse.axd from, as it is causing issues with other javascript on the page

我如何禁用脚本经理在这些网页上?

How can I disable the script manager on these pages?

使用ScriptManager对象犯规似乎有这似乎像他们会做这项工作的任何属性。

The ScriptManager object doesnt appear to have any properties that would seem like they would do the job

这可能吗?

推荐答案

将您的&LT ASP MyScriptManager.ascx - 在.ascx文件只有code将是ScriptManager的标签 - 那么你可以设置在可见在自定义的控件属性来控制的ScriptManager是否会被渲染

Move your <asp:ScriptManager /> to a custom control e.g. MyScriptManager.ascx - the only code in the .ascx file will be the ScriptManager tag - then you can set the Visible property on your custom control to control whether the ScriptManager gets rendered.

<foo:MyScriptManager id="scriptManager" runat="server" Visible="false" />

您可以甚至添加属性到你的母版,你可以在你的内容页面用来显示/隐藏的ScriptManager:

You could maybe even add a Property to your MasterPage which you could use in your content pages to show / hide the ScriptManager:

// In your master page
public bool ShowScriptManager {get; set;}

// In your master page's Page_Load
private void Page_Load(object sender, EventArgs e) {
    ...
    scriptManager.Visible = ShowScriptManager;
    ...
}

由于大部分页面都需要ScriptManager的,它可能是一个想法,使其默认为真 - 我想你可以在你的母版页的Page_Init方法构造做到这一点:

As most of your pages require the ScriptManager, it might be an idea to make it default to true - I think you can do this in your Master Page's constructor of Page_Init method:

public SiteMaster() {
    ...
    ShowScriptManager = true;
    ...
}

// Or alternatively
private void Page_Init(object sender, EventArgs e) {
    ...
    ShowScriptManager = true;
    ...
}

然后,如果你设置中的MasterType在你的内容的网页:

Then, if you've set the MasterType in your content pages:

<%@ MasterType VirtualPath="~/path/to/master/page" %>

您只需要在做这样的事情内容页的的Page_Load

You just need to do something like this in content page's Page_Load:

Master.ShowScriptManager = false;

这篇关于禁用ScriptManager的某些网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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