0

I have a website in sp 2010, in which I need to add a Home button on one of the webpages, which can redirect to home page . The requirement is that, i cannot use hardcoded URL for the home page. I have tried using linkbuton using postback url property but cant get it right. Please provide me suggestions or solution.

  • Can you explain the "requirement"? Why not just use a hard-coded URL to link to an absolute page? That would certainly be the easiest and most straight-forward solution. Is this homework for a course or assignment? – teylyn Jul 8 '13 at 10:59
  • @teylyn we are not allowed to used hard coded values, in order to follow best practices. Also this is a part of course assignmnet. – Deepika Jul 11 '13 at 5:19
0

You could use a javascript command:

var baseUrl = location.protocol +'//'+ document.location.hostname

or

var baseUrl = location.origin

e.g.: if your current url is http://server1/sites/test1/Lists the commands above will give you http://server1

0

I solved the issue by using the below code on button click

'string URL = SPContext.Current.Web.Url;

Response.Redirect(URL);'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.