Fetching Sharepoint site logo URL and navigate to root site

Hi,

I have a publishing site having a custom Master page.

In the Master page, i have the below code for the logo, which on click shows the root site.

<SharePoint:SPLinkButton CssClass="ms-siteicon-a" runat="server" NavigateUrl="~sitecollection/" id="onetidProjectPropertyTitleGraphic" >
			
<SharePoint:SiteLogoImage CssClass="ms-siteicon-img" name="onetidHeadbnnr0" id="onetidHeadbnnr2" LogoImageUrl="/_layouts/15/images/siteIcon.png?rev=23" runat="server"/>
</SharePoint:SPLinkButton>

I am trying to access this in the user control . I am creating a footer which shows the current year and on click should redirect to the root site.

I tried this:

string currentTime = System.DateTime.Today.Year.ToString();
var v = "";

var tcOne = (SPLinkButton)this.Parent.Page.Master.FindControl("onetidProjectPropertyTitleGraphic");
                      
if (tcOne != null)
{
    v = tcOne.NavigateUrl;
}

value = value + "<a id='footerCopyRgt' href='" + v + "'> &#169; " + currentTime + " </a>";

When i deployed and when opened the page in subsite, for the year on hover of it, i am getting as :

http://server/sites/ParentSite/TestSubsite/Pages/~sitecollection/

How to fix this? How to navigate to the root site?

I am looking for the URL as :

http://server/sites/ParentSite/

Thanks


March 24th, 2015 1:31am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics