Trying to retrieve the primary and secondary site administrators using javascript and show them in the labels on custom Access Denied page. Using the code below(inline javascript) to do that but ExecuteOrDelayUntilScriptLoaded(myfunction, "sp.js");
(also used SP.SOD.ExcuteFunc()
but of no use) does not get executed. Am I missing something?
<asp:Content ID="Content5" ContentPlaceHolderId="PlaceHolderMain" runat="server">
<script type="text/javascript">
SP.SOD.registerSod("sp.js", "\_layouts\SP.js");
// RegisterSodDep("inplview", "sp.js");
debugger;
alert("begin");
var currentContext;
alert("before method");
ExecuteOrDelayUntilScriptLoaded(myfunction, "sp.js");
function myfunction() {
alert("Entering into function");
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 method");
//alert("After");
function onRequestSucceeded() {
alert("inside onrequest");
var primarySiteContact = this.props.get_item('GA_PrimarySiteCollectionContact');
var secondarySiteContact = this.props.get_item('GA_SecondarySiteCollectionContact');
var elem = document.getElementById('lblPrimary');
elem.innerHTML = primarySiteContact;
alert(primarySiteContact);
var elem2 = document.getElementById('lblSecondary');
elem2.innerHTML = secondarySiteContact;
alert(secondarySiteContact);
}
function onRequestFailed(sender, args) {
alert('Error: ' + args.get_message());
}
</script>
_spBodyOnLoadFunctionNames.push("myfunction");