JavaScript在MSVS上执行并运行,但在发布时不起作用

时间:2015-06-19 02:31:33

标签: javascript c# asp.net visual-studio-lightswitch

我正在使用Lightswitch,我正在使用此javascript根据当前用户权限隐藏一些按钮。我正在关注MSDN上的这个教程:

https://msdn.microsoft.com/en-us/library/ff852062.aspx

这是我的页面

/// <reference path="~/GeneratedArtifacts/viewModel.js" />

myapp.Inicio.VisualizarAgenda_execute = function (screen) {
window.location = "../WebForms/Agenda.aspx";
};
myapp.Inicio.VisualizarCorridaExecutadaCompleta_execute = function (screen) {
// Write code here.
window.location = "../WebForms/CorridaExecutadaCorridaCompleta.aspx";
};

myapp.Inicio.ColetaMotoristaCorridas_execute = function (screen) {
window.location = "../WebForms/ColetaMotoristaCorrida.aspx";
};

myapp.Inicio.created = function (screen) {
//screen.getCanExecuteClientes().then(function success() {
//    screen.findContentItem("ShowBrowseClientes").isVisible = true;
//}, function error() {
//    screen.findContentItem("ShowBrowseClientes").isVisible = false;
//})

//screen.getCanExecuteMotoristas().then(function success() {
//    screen.findContentItem("ShowBrowseMotoristas").isVisible = true;
//}, function error() {
//    screen.findContentItem("ShowBrowseMotoristas").isVisible = false;
//})

//screen.getCanExecuteVeiculos().then(function success() {
//    screen.findContentItem("ShowBrowseVeiculoes").isVisible = true;
//}, function error() {
//    screen.findContentItem("ShowBrowseVeiculoes").isVisible = false;
//})

screen.getCanExecuteEnderecosCorrida().then(function success() {
    screen.findContentItem("ShowBrowseEnderecoCorridas").isVisible = true;
}, function error() {
    screen.findContentItem("ShowBrowseEnderecoCorridas").isVisible = false;
})

screen.getCanExecuteCorridas().then(function success() {
    screen.findContentItem("ShowBrowseRotas").isVisible = true;
}, function error() {
    screen.findContentItem("ShowBrowseRotas").isVisible = false;
})

screen.getCanExecuteCorridasAgendadas().then(function success() {
    screen.findContentItem("ShowBrowseProgramacoesRota").isVisible = true;
}, function error() {
    screen.findContentItem("ShowBrowseProgramacoesRota").isVisible = false;
})

screen.getCanExecuteCorridasExecutadas().then(function success() {
    screen.findContentItem("ShowBrowseCorridaEsporadicas").isVisible = true;
    screen.findContentItem("ShowBrowseCorridas").isVisible = true;
}, function error() {
    screen.findContentItem("ShowBrowseCorridaEsporadicas").isVisible = false;
    screen.findContentItem("ShowBrowseCorridas").isVisible = false;
})

screen.getIsMotoristaQuery().then(function success() {
    screen.findContentItem("Cadastros").isVisible = false;
    screen.findContentItem("Fechamento").isVisible = false;
    screen.findContentItem("Relatorios").isVisible = false;
    screen.findContentItem("Basicos").isVisible = false;
    //screen.findContentItem("ShowBrowseColetaMotoristaCorridas").isVisible = true;
}, function error() {
    screen.findContentItem("Cadastros").isVisible = true;
    screen.findContentItem("Fechamento").isVisible = true;
    screen.findContentItem("Relatorios").isVisible = true;
    screen.findContentItem("Basicos").isVisible = true;
    //screen.findContentItem("ShowBrowseColetaMotoristaCorridas").isVisible = false;
})

};

我的问题是:当我在调试时,它完美无缺。当我在自己的计算机上部署时,仍然有效。 当我在IIS上托管的Windows Server上部署时,没有任何反应。

使用两种浏览器进行测试(服务器内部为本地,我的开发计算机上本地,与服务器不在同一网络上)

1 个答案:

答案 0 :(得分:0)

如果你通过从渲染的html中处理它来使用控件的id,那么在部署它时它可能不起作用。 你必须在jquery中使用类选择器来实现这个或找到内容项的真实id,或者你可以使用静态id,如果你使用的是.net 4及以上版本。