asp.netdotnetnukeclient-dependency

window.dnnLoadScriptsInAjaxMode undefined in page administration module


I have a problem with my development machine dotnetnuke installation. When I try to load the content of the page administration module under "Admin / Page Management", I get a JavaScript error

pages:2089 Uncaught TypeError: Cannot read property 'length' of undefined

Wich is because window.dnnLoadScriptsInAjaxMode is undefined

var loadScriptInMultipleMode = function(){
    for(var i = 0; i < window.dnnLoadScriptsInAjaxMode.length; i++){

When I look into the page code I can see and debug that the following if check fails: "item.indexOf('$crm_')" is not working.

(function($){
Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(function (sender, args){
var dataItems = args.get_dataItems();
for(var item in dataItems){
    if(item.indexOf('$crm_') > -1){
        var content = dataItems[item];
        ...

Because dataItems contains all values for the ClientDependency placeholders with underscore "_" as a prefix. e.g "_crm_BodySCRIPTS" instead of dollar sign "$" "$crm_BodySCRIPTS", which is what the code expects.

In our production instance everything is working fine and I can not remember changing any prefix configuration for the ClientDependency Framework. Combining and minifying files is turned of as in the Administration.

Can anybody help with what could be wrong here?

UPDATE: I can see in Github Line:172 https://github.com/dnnsoftware/Dnn.Platform/blob/development/DNN%20Platform/DotNetNuke.Web.Client/Providers/DnnBodyRenderProvider.cs that this is hardcoded. So I must have somehow already set a ScriptManager without knowing.

How can this be?


Solution

  • The problem is caused by setting the clientIDMode attribute in web.config for pages.

    <pages validateRequest="false" enableViewStateMac="true" enableEventValidation="true" viewStateEncryptionMode="Never"  clientIDMode="AutoID">
    

    As the description from Microsoft states:

    The ClientID value is generated by concatenating the ID values of each parent naming container with the ID value of the control. In data-binding scenarios where multiple instances of a control are rendered, an incrementing value is inserted in front of the control's ID value. Each segment is separated by an underscore character (_). This algorithm is the only one that was available in versions of ASP.NET earlier than ASP.NET 4.

    The attribute causes the change of $ to underscore for the ClientID property which is then used to render dataitems with ID "_crm". This way the clientside check fails.

    If you remove the attribute everything works again.