Search code examples
javascriptdotnetnukeskinning

DNN Client Side Variables


In DNN, how can I get portal settings like page id, portal language, etc as a variable for javascript? I have tried something like this:

<% DotNetNuke.UI.Utilities.ClientAPI.RegisterClientVariable(Me.Page, "pageTitle", PortalSettings.ActiveTab.TabName, True) %>

and

var pageTitle = dnn.getVar('pageTitle');

but no luck, it just shows that variable "PageTitle" is undefined.


Solution

  • Example from: https://github.com/ChrisHammond/dnnCHAT/blob/master/View.ascx

    <script type="text/javascript">
       var moduleId:<%= ModuleId %>;
       var tabId:<%= TabId %>;
    </script>
    

    Where ModuleId is the parameter you want to set. If you're doing something with portalsettings you could do PortalSettings.PortalName, or any other valid value.