Tuesday, June 17, 2008

How access relative url of site in Sharepoint-Used in master pages



If you are creating the master pages in SharePoint. In this master page
you have created the image tab and you want to linked this image tab
with the particular page(for example publish page in Sharepoint) from
the SharePoint site(or site collection). Another use of relative url is
if you are referencing resources such as style sheets, images,
JavaScript etc in a SharePoint environment you need to be careful to
ensure that URLs are relative to the current site (or site collection)
so that if sites are moved the references don’t break.

For example you have created the image tag :







Now you want to linked this image tab with AboutUs page(for example publish page in Sharepoint) of your current SharePoint site(or site collection in SharePoint):

i. For Site URL(relative site url in sharepoint):






In the above anchor tag(i.e. tag a) we have written the runat="server", its mean we are
telling to the sharepoint engine that its is a server side control not client site.

ii. For Site Collection URL(relative site collection url in sharepoint):








In the above anchor tag(i.e. tag a) we have written the runat="server", its mean we are
telling to the sharepoint engine that its is a server side control not client site.

We can use relative url in master pages, page layouts or other pages on the site by
using the SPUrl expression. SPUrl define prefix provided by the
Microsoft.SharePoint.Publishing.WebControls.SPUrlExpressionBuilder class.



Share:

0 comments:

Sitecore® Technology MVP 2019

Featured Post

Sitecore Error Troubleshooting: Sitecore Solr Connectivity Issue:: Part-1

Sitecore Error Troubleshooting: Sitecore Solr Connectivity Issue:: Part-1 How to verify Sitecore 9.1 (IaaS and Azure PaaS) + Solr (IaaS) C...

Total Pageviews

State Counder

Popular

About Me

My photo
Based in Bangalore, INDIA, Amit is a Sitecore MVP and MCC. He has an MCA from the U.P.T.U., INDIA and holds certifications including Sitecore and SharePoint 2007/2010. He is an contributor to Sitecore/MSDN communities and http://amitkumarmca04.blogspot.com/. Amit have experience in Sitecore, ASP.Net with C#, MVC, SharePoint, Classic ASP, VB,Macros,HTML,JavaScript,JSON,BootStrap and AngularJS.

Followers

Follow me on Twitter

Labels