Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm using a DataFormWebPart with an embedded SoapDataSource. The problem is that SoapDataSource needs to have the full url of the site (http://server/_vti_bin/Myservice.asmx) to work. This makes moving between servers very tricky, as I have to manually update the fields each time. Also as the site collection is to be extended into internal and internet zones this adds another wrinkle. So far I have tried, <% $SPURL:~sitecollection/...%> which does give me a relative URL, and plain ~site/~sitecollection are not replaced. Is there away to embed SPCurrent.Web.URL into the webpart that isn't discarded by SharePoint designer? What other methods are there?

I'm trying to avoid coding this (Which is easily done) so I can avoid adding complexity when none should be needed.

share|improve this question
add comment

2 Answers

I was exploring this last week and have not found any way to make the URL dynamic. I tried the same methods. The only viable solution I found was to create it with jQuery and SPServices, as SPServices uses the current site as the default when hitting the web services.

This comes with the detriment that everything is done client side rather than server side.

share|improve this answer
    
Yeah that would be an option for simple things, but I need extensive XSLT formatting. Don't think jQuery will make things easier. –  Jasper Feb 13 '12 at 8:19
    
Yep, I even pinged some of my go to people for DVWPs about it too. Client side was the only way I could make it dynamic (I'm not a Visual Studio guy). –  PirateEric Feb 13 '12 at 13:16
    
Ok, thanks for that. I am a Visual Studio guy, so I'm hoping for a solution in that area. –  Jasper Feb 13 '12 at 16:08
1  
@Jasper I was one of the guys that looked into this for PirateEric. From what I learned and was told, it's impossible. I wish there was a better answer, but I'm afraid the DVWP isn't that flexible. –  iOnline247 Feb 14 '12 at 2:00
add comment

There is a JavaScript Variable on SharePoint pages called _spPageContextInfo. Read more about it here: http://blog.tedpattison.net/Lists/Posts/Post.aspx?ID=9

_spPageContextInfo.siteServerRelativeUrl gives you the relative url of the current Site Collection. _spPageContextInfo.webServerRelativeUrl gives you the relative url of the current web.

Combine that with window.location.href and with a few string operations you can get the current url.

share|improve this answer
    
Don't see how that would help me. The URL is needed for the soap data source parameter, which is being evaluated serverside as far as I know. The Javascript will only work clientside, after the data has already been retrieved. I don't know if there's a way to change the datasource URL client side, never heard of it. –  Jasper Feb 13 '12 at 7:30
add comment

Your Answer

 
discard

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.