Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

How Do I do That?

  Asked By: Arnold    Date: Aug 05    Category: Sharepoint    Views: 687

I have a web application that pulls items from a Work Priorities list on each of the teams sites under the Sites Directory and displays selected fields on a page. I display the page in a PageViewer Web Part on the portal Home page.

The problem is that I have had to hard code the URLs for each of the team sites in order for it to work using:

Dim Teamsite1 As New SPSite(http://[servername]/sites/1)
Dim Teamsite2 As New SPSite(http://[servername]/sites/2)
Dim Teamsite3 As New SPSite(http://[servername]/sites/3)
Dim Teamsite4 As New SPSite(http://[servername]/sites/4)
Dim Teamsite5 As New SPSite(http://[servername]/sites/5)

I then pass these to a subroutine that does the work:

showItems(Teamsite1,"1")
showItems(Teamsite1,"2")
showItems(Teamsite1,"3")
showItems(Teamsite1,"4")
showItems(Teamsite1,"5")



Sub showItems(ByVal teamsite As SPSite, ByVal dir As String)

Dim site As SPWeb

site = teamsite.AllWebs("")

Dim i As Integer

Dim lists As SPListCollection = site.Lists

Dim j As Integer

For j = 0 To lists.Count - 1

If Trim(lists(j).Title) = "Work Priorities" Then

Dim listItems As SPListItemCollection = site.Lists("Work Priorities").Items

Dim l As Integer

Response.Write("<TABLE border=0>")

Response.Write("<TR><TH colspan=4 class='ms-ToolStrip''><a href='" & site.Url & "/Shared%20Documents/Work%20Summary.aspx' target='_blank'>" & dir & "</a></TH></TR>")

Response.Write("<TR><TH class='ms-toolbar'>Status</TH><TH align='left' class='ms-toolbar'>Action</TH><TH align='left' class='ms-toolbar'>Goal</TH><TH align='left' class='ms-toolbar'>ATSC Lead</TH></TR>")

Response.Write("<TR><TD colspan=4><HR /></TD></TR>")

For l = 0 To listItems.Count - 1

Dim item As SPListItem = listItems(l)

............

End Sub

What I can't figure out is how to get this to work on multiple portal sites. Right now I have the application configured on each of our portals but it is only pulling from the hard coded sites which may or may not be on the portal that is viewing the page.

What I want to do is have the application pull from from the sites relative to the portal that the page is being viewed from;e.g. If I'm am on the development portal [devportal] then the items wouild be pulled from the teamsites on [devportal] and if I am on the production portal [prodportal] then they will bne pulled from the [prodportal].

I have tried:

Dim mySite3 As SPSite = SPControl.GetContextSite(Context)



Dim myWeb As SPWeb = mySite3.AllWebs("")
Dim strServer As String

strServer = myWeb.Url & "/sites/1"

Dim 1siteCollection As New SPSite(strServer)

showItems(1siteCollection, "1")

But I get a:

System.IO.FileNotFoundException: The Web site that is referenced here is not in the configuration database.

When I do a trace.warn on strServer it shows as the same string that I hard coded. ????

According to the SDK :

[Visual Basic .NET]

Dim siteCollection As New SPSite(http://Server_Name/sites/Site_Name/Subsite_Name/default.aspx)

[Visual Basic .NET]

Dim siteCollection As New SPSite("http://" & System.Environment.MachineName & "/sites/Site_Name")

So why can't I pass it a string?

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on How Do I do That? Or get search suggestion and latest updates.




Tagged: