Skip to main content
Home  ›  Docs › Feature

Dnn Objects in Razor

Warning ⚠️: New Docs Available

These are old docs and we haven't found the time to completely move them. You will find comprehensive new docs on docs.2sxc.org.

Introduced in Version 01.00

When you're using Razor templates you can access the important DNN objects through the variable called Dnn. 

So for quick binding of the ModuleId you would do something like 

  • <div>@Dnn.Module.ModuleID</div>
  • <div id="form@Dnn.Module.ModuleID</div>
  • @{ var mid = Dnn.Module.ModuleID; }

The objects attached to the DNN are the standard Razorhost DNN-Variables, namely

  1. Dnn.Module - the current module
  2. Dnn.Tab - Information about the current page
  3. Dnn.Portal - the portal we're on
  4. Dnn.User - the current user

This is the data-type (and a link to some older documentation) of each object (see the Dnn-Code on Github)

  1. Dnn.Module is ModuleInfo
  2. Dnn.Tab is a TabInfo
  3. Dnn.Portal is a PortalSetting
  4. Dnn.User is a UserInfo

The full list of APIs, Properties etc. can be found in the API-docs

Tags for this feature
Razor DNN/DotNetNuke