Following is the C# code which lists out the names and their links of all subsites which the user has got permissions.
protected override void Render(HtmlTextWriter writer)
{
SPSite site = SPContext.Current.Site;
SPWeb web = site.OpenWeb();
SPWebCollection sites = web.GetSubwebsForCurrentUser();
foreach (SPWeb subSite in sites)
{
writer.Write(
subSite.Url
SPEncode.HtmlEncode(subSite.Title)
}
}
inside the writer. write, use a href and line breaks (br) properly so that subsite.url will come inside the a href and 'spencode.htmlencode(subsite.title)' will come in between the opening and closing tags of a href.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment