var context = null;
var web = null;
function ShowAllSubsites()
{
try
{
context = new SP.ClientContext.get_current();
web = context.get_web().get_webs();
context.load(web);
context.executeQueryAsync(Function.createDelegate(this, this.SubWebsSuccessMethod), Function.createDelegate(this, this.SubWebsFailedMethod));
}
catch(Ex)
{
alert(Ex);
}
}
function SubWebsSuccessMethod(sender, args)
{
var strSubwebs="";
strSubwebs+="<Table>";
strSubwebs+="<Tr>";
strSubwebs+="<Td class='HeadingClass'>";
strSubwebs+="SubWeb Name";
strSubwebs+="</Td>";
strSubwebs+="</Tr>";
for(var i=0;i<this.web.get_count();i++)
{
var strSubWeb=this.web.itemAt(i);
var strSubWebUrl=strSubWeb.get_serverRelativeUrl();
var strSubwebTitle=strSubWeb.get_title();
strSubwebs+="<Tr>";
strSubwebs+="<Td class='LoopRecordsClass'>";
strSubwebs+="<a href='"+strSubWebUrl+"'>"+strSubwebTitle+"</a>";
strSubwebs+="</Td>";
strSubwebs+="</Tr>";
}
strSubwebs+="</Table>";
$("#divSubWebs").html(strSubwebs);
}
ExecuteOrDelayUntilScriptLoaded(ShowAllSubsites, "sp.js");
function SubWebsFailedMethod(sender, args)
{
alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
}
var web = null;
function ShowAllSubsites()
{
try
{
context = new SP.ClientContext.get_current();
web = context.get_web().get_webs();
context.load(web);
context.executeQueryAsync(Function.createDelegate(this, this.SubWebsSuccessMethod), Function.createDelegate(this, this.SubWebsFailedMethod));
}
catch(Ex)
{
alert(Ex);
}
}
function SubWebsSuccessMethod(sender, args)
{
var strSubwebs="";
strSubwebs+="<Table>";
strSubwebs+="<Tr>";
strSubwebs+="<Td class='HeadingClass'>";
strSubwebs+="SubWeb Name";
strSubwebs+="</Td>";
strSubwebs+="</Tr>";
for(var i=0;i<this.web.get_count();i++)
{
var strSubWeb=this.web.itemAt(i);
var strSubWebUrl=strSubWeb.get_serverRelativeUrl();
var strSubwebTitle=strSubWeb.get_title();
strSubwebs+="<Tr>";
strSubwebs+="<Td class='LoopRecordsClass'>";
strSubwebs+="<a href='"+strSubWebUrl+"'>"+strSubwebTitle+"</a>";
strSubwebs+="</Td>";
strSubwebs+="</Tr>";
}
strSubwebs+="</Table>";
$("#divSubWebs").html(strSubwebs);
}
ExecuteOrDelayUntilScriptLoaded(ShowAllSubsites, "sp.js");
function SubWebsFailedMethod(sender, args)
{
alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
}
No comments:
Post a Comment