Search code examples
sharepoint-2010web-parts

Relative url in Visual web part


In my Visual web part I'm using relative url like following and it's working fine . But I assume it will not work when I deploy my project in different site structure on another server. So my question is how to make links,urls dynamic which will work in all the scenarios.

../../something.aspx 

Please note I have some JQuery files included in <script> tag I can't only rely on building dynamic url using code.


Solution

  • Rishi,

    Are you using a document library to store the page? If so, you could use SPDocumentLibrary.DefaultViewURL. If you're trying to navigate to a different web, then you can get a web's URL from SPWeb.Url.

    Best, -Tony