How to get DotNetNuke ModuleID using jquery?

All,

I am developing a dnn 6 module and cannot find a way to get ModuleID using jQuery. ModuleID is not in the request and seems to be stored in context. Does anyone know how to get ModuleID using jQuery if it doesn't display in querystring?

One of the ways I tried to do this is to use the asp: label control and when loading the page, assign the ModuleID to the label, and then use jQuery to get this .val () of this label. However, I don’t want ModuleID to just show on the page - this is stupid! :)

Thanks for any advice!

+4
source share
2 answers

You can simply display the ModuleId inside the <script> tag in View.ascx:

<script> var moduleId = <%= ModuleId %>; </script> 
+4
source

Well, that would be the only way, if you do not want the identifier on the page you could also have a hidden range, provide this module moduleid, then add moduleid to the data-moduleid of the data attribute and then read it using jquery

 <span class="moduleid" data-moduleid="<%=ModuleControl.ModuleContext.ModuleId%>"></span> 
0
source

All Articles