我想使用JavaScript在DotNetNuke中获取当前用户名,并在一些js功能中使用它,例如:
alert(DotNetNuke.User.Name)
The easiest way is to add a Text/HTML
module to a page.
In the module settings of that module, check the Replace Tokens
option on the HTML Module Settings
tab.
Now you can use the tokens and add text to that module (use Basic Text Box when using JavaScript).
<script> alert('Hello my name is [User:DisplayName]'); </script>
Full list of tokens here .
Another way could be
alert('<%= UserController.Instance.GetCurrentUserInfo().DisplayName %>')
but you have to import:
<%@ Import Namespace="DotNetNuke.Entities.Users" %>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.