SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to join absolute and relative URL parts of a sharepoint site in <a href="http://somesite"> tag.

i already have this:

strng.Format(@"<a href=""/_layouts/something/Mypage.aspx?workflowID={0}"">{1}</a>", workflowguid, ItemRow["Title"].ToString());

I want to add absolute URL part like this:

strng.Format(@"<a href=""SPContext.Current.Web.Url/_layouts/something/Mypage.aspx?workflowID={0}"">{1}</a>", workflowguid, ItemRow["Title"].ToString());

But, its incorrect, it considers "SPContext.Current.Web.Url" as series of characters, I want output should be like this:

strng.Format(@"<a href=""{0}"">{1}</a>", workflowguid, ItemRow["Title"].ToString());

How i fix this ??

share|improve this question
up vote 0 down vote accepted

I think this is what your looking for ;)

strng.Format(@"<a href="""+SPContext.Current.Web.Url+"/_layouts/something/Mypage.aspx?workflowID={0}"">{1}</a>", workflowguid, ItemRow["Title"].ToString());

in code using "SPContext.Current.Web.Url" will show SPContext.Current.Web.Url but if you do it outside of the "" than it will show

but dont you mean to use SPContext.Current.Site

strng.Format(@"<a href="""" "+SPContext.Current.Site+"/_layouts/something/Mypage.aspx?workflowID={0}"+"\"\""+">{1}</a>", workflowguid, ItemRow["Title"].ToString());
share|improve this answer
it now shows but still some "" are missing at the end.. Can u check it again? – SPBeginer Jan 18 '13 at 14:28
can you copy past the result? so i know where its missing! – ali Sharepoint Jan 18 '13 at 14:29
it shows red underline near: ">{1}</a>", workflowguid, ItemRow – SPBeginer Jan 18 '13 at 14:34
ok iv just editited the answer, copy paste the bottom example :) , iv added \ after each double quote to say its a litral double quote to be displayed :) – ali Sharepoint Jan 18 '13 at 14:34
still not correct... ?? whol is redunderlined now..? – SPBeginer Jan 18 '13 at 14:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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