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:

About Me

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

Followers

Labels