jquery 不在已发布的站点中工作,但在开发环境中工作

jquery not working in published site but working in development environment

我使用 jquery 更改 asp.net 页面中某些元素的样式,如下所示

protected void Page_Load(object sender, EventArgs e)
    {
        string scrp3 = "$(document).ready(function () {if ($('#MainContent_chbkCooperation_1').is(':checked')) {if (!$('#MainContent_chbkCooperation_0').is(':checked')) {$('.pajooheshVal').hide();}}});";
        ScriptManager.RegisterStartupScript(this, GetType(), ClientID, scrp3, true);
    }

在我的本地测试中,这种样式有效,但当它在服务器上发布时,它不起作用,并且样式保持不变。

注:

我的页面中有多个更新面板并使用 ms-ajax。 我如何在页面的每个完整和异步回发中隐藏我的元素?

我从客户端解决了这个问题,如下所示:

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoaded);

function PageLoaded(sender, args) {
        var prm = Sys.WebForms.PageRequestManager.getInstance();
        if ($('#MainContent_chbkCooperation_1').is(":checked")) {
            if (!$('#MainContent_chbkCooperation_0').is(":checked")) {
                $('.pajooheshVal').hide();
            }
        }
    }

这帮助我在页面的每个异步回传上 运行 jQuery。 对于完整的回发,我使用了 jquery 它自己。