我想使用javascript检索主要和辅助站点管理员,并在自定义拒绝访问页面上的标签中显示它们。使用下面的代码(内联javascript)来做到这一点,但SP.SOD.ExcuteFunc()不会被执行。我错过了什么吗?
<asp:Content ID="Content5" ContentPlaceHolderId="PlaceHolderMain" runat="server">
<script type="text/javascript">
SP.SOD.RegisterSod("sp.js", "\_layouts\sp.js");
</script>
<script type="text/javascript">
debugger;
alert("check");
var clientContext;
var siteCollection;
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', getAdmin);
function getAdmin(){
alert("Entering into function");
var currentContext = SP.ClientContext.get_current();
//alert("1");
var siteColl = clientContext.get_site();
var rootWeb = siteColl.get_rootWeb();
this.props = rootWeb.get_allProperties();
clientContext.load(rootWeb);
clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
//alert("end");
}
//alert("After");
function onRequestSucceeded()
{
alert("inside onrequest");
var primarySiteContact = this.props.get_item('GA_PrimarySiteCollectionContact');
var secondarySiteContact = this.props.get_item('GA_SecondarySiteCollectionContact');
elem = document.getElementById('lblPrimary');
elem.innerHTML = primarySiteContact;
alert(primarySiteContact);
}
function onRequestFailed(sender, args)
{
alert('Error: ' + args.get_message());
}
</script>
<table border="0" cellpadding="0">
<asp:Panel id="PanelUserName" runat="server">
<tr>
<td class="ms-sectionheader">
<img src="/_layouts/images/ListSet.gif" alt="" />
<SharePoint:EncodedLiteral ID="EncodedLiteral3" runat="server" text="<%$Resources:wss,accessDenied_currentuser%>" EncodeMethod='HtmlEncode'/>
</td>
</tr>
<tr>
<td valign="top" class="ms-descriptiontext"><SharePoint:EncodedLiteral ID="EncodedLiteral4" runat="server" text="<%$Resources:wss,accessDenied_loggedInAs%>" EncodeMethod='HtmlEncode'/>
 <b><asp:Label id="LabelUserName" runat="server"/></b>
</td>
</tr>
</asp:Panel>
<tr>
<td> </td>
</tr>
<tr>
<td>
<asp:HyperLink id="HLinkLoginAsAnother" Text="<%$SPHtmlEncodedResources:wss,accessDenied_logInAsAnotherOne%>"
CssClass="ms-descriptiontext" runat="server"/>
<br/>
<asp:HyperLink id="HLinkRequestAccess" Text="<%$SPHtmlEncodedResources:wss,accessDenied_requestAccess%>"
CssClass="ms-descriptiontext" runat="server" /><br /><br />
<asp:Label id="Label1" runat="server" Text="Please contact the below mentioned site owners" /><br/>
<asp:Label id="lblPrimary" runat="server" /><br/>
<asp:Label id="lblSecondary" runat="server" />
</td>
</tr>
</table>
</asp:Content>