Open SharePoint 2010 list item via custom web part - sharepoint-2010

On my SharePoint 2010 site I have a list of items (Document Library). This library contains xml files.
Also, I have a Visual Web Part which displays data from these xml files.
Is there a way to somehow bind the web part to this document library so that the items will be opened via the web part?
Note:
At this point the list item has a hyperlink field which points to the web part page and provides the location of xml file as query string. When the link is accessed, the web part gets provided xml data and parses it as it should.
The problem with this approach is that an absolute url is saved in item's field, which will result into problems when server is changed.
Thank You!

Look into the Sharepoint 2010 "Related List" feature. Sharepoint 2010 allows to send and receive data between webparts, so even your custom webpart.
See the following link for a how-to: SP 2010: How To - Relational lists in SharePoint 2010

Related

Programmatically accessing a Sharepoint list at runtime (without creating a service reference at design time)

I'm creating an app that will be configurable by the end-user to access SharePoint lists, on various different SharePoint sites, that are entered by the user.
All of the examples for reading SharePoint lists I've come across online are of the form:
Open or create a Visual Studio
project.
In Solution Explorer,
right-click the References node, and
then click Add Service Reference.
In the Address box, type the URL to
the target site and append
/_vti_bin/ListData.svc. For example,
the address for the site
intranet.wingtip.com would be
http://intranet.wingtip.com/_vti_bin/ListData.svc.
Change the default name in the
Namespace box from ServiceReference1
to something more appropriate, such
as WingtipSite.
etc, etc, etc
This method creates proxy classes within your project based on the specified server reference. However, in my case, the server/site is not known at design time, only runtime by reading the sites/lists specified by the user. How would one go about doing that (reading the list via http://intranet.wingtip.com/_vti_bin/ListData.svc, but at runtime only)?
Note: I am making this call from a different machine than the one running Sharepoint.
There are a couple answers.
If the lists schemas will be consistent across all the sites you are querying, you can still use the generated proxy. When you create the DataContext, you just need to pass in the URI to the ListData.svc for the site chosen by the user.
If not, then you can use an ASP.NET WebRequest with an appropriately formatted URI and parse out the ATOM or JSON response that comes back.
For more information on using the REST APIs, check out this talk from the 2009 SharePoint Conference
http://msdn.microsoft.com/en-us/sharepoint/ff462048
You can set the URL in your proxy class at runtime with the Url property.
SharePoint does not provide a proxy class for their web services. Therefore it's not possible to set the url at runtime. WHat I have had to do is add 2 service references and then paramaterize which one I will access. I use a config setting to determine which one to access. If the site name changes or list changes, then I need to remove the references, re-add them, recompile and redeploy. There is no way to change the SharePoint site/list at runtime. Have been searching for 3 days for an answer. Microsoft does not know how to accomplish this.

How to add bunch of aspx files to a site definition sp2010 vs2010 project

I need to be able to deploy bunch of aspx files when a site (sub-site aka web) is provisioned. I added a feature but it seems whole feature thing has changed with vs 2010 or sp2010. I am totally lost. All I want to do is to deploy these pages when a web is provisioned. Is it possible?
You can't drop aspx pages into SharePoint per say. If you want to add functionality, some of the options are:
1) Using Web Parts - probably the most popular method
2) User Controls
At the end of the day, you will create it as a Feature using VSeWSS 3.0 in VS and packaging/deploying it as a solution. Steer clear of trying to hack this up in SharePoint Designer - for one, you won't have source control like you have with a Feature.
http://www.andrewconnell.com/blog/articles/UsingCodeBehindFilesInSharePointSites.aspx
http://www.codersbarn.com/?tag=/webpart

using Search Server 2010 Express web service results are returning .aspx pages instead of documents

I have a Search web reference (from a Search Server 2010 express install) in a vb.net application that is utilizing the QueryService Class to search a production Sharepoint foundation 2010 site.
At a previous point in time, we had created a proof of concept on an entirely test system that has since been turfed. From my recollection on this test system when documents were uploaded as a specific site content type (that inherits from document) and metadata was provided, we could search for specific metadata by making managed properties for each, and search results would be returned as documents (with the isdocument flag set to true). Viewing the document then became simple, as we could simply use the filename and path to display the stored file.
Now we are developing a production system and we have encountered a new behavior, where these results now are returned as aspx results such as
http://digitizaton/Company/Client Documents/Forms/DispForm.aspx?ID=1703
This of course makes it terribly difficult to locate and view the document, we can extract the Title which will then give us the name of the file with no extension, but that hardly helps, as the FileExtension data is aspx, not the documents file extension, so we don't have a full filename. We could display the page returned as a result, but would much prefer the document itself.
I've made a test document library, with just bare bones setup, (not using the site content type, or site columns) and uploaded some documents on the same site, and they are returned in the same fashion, so I don't believe the document library, or content type are the issue.
With a fairly limited understanding of both Sharepoint and Search Server, I don't know if this is a setup issue with the search service itself, with the site configuration, or with the querypacket I am sending. We also have a third party application (Knowledgelake) installed on the server that ties into sharepoint which could have changed configuration somewhere as well?
I don't think the query packet has changed since it was working in the proof of concept, other than the custom data column names. I will provide it here in case there is something glaringly obvious to an external reader.
<QueryPacket xmlns='urn:Microsoft.Search.Query.Document'>"
<Query>
<SupportedFormats>
<Format>urn:Microsoft.Search.Response</Format>
</SupportedFormats>
<Range>
<Count>0</Count>
</Range>
<Context>
<QueryText type='MSSQLFT'>
SELECT Filename, Title, FileExtension, IsDocument, Path from Scope() WHERE ""Scope"" = 'Department1' AND CustomData = 'X' --
</QueryText>
</Context>
Any guidance would be incredibly appreciated. If I have not provided some relevant information, please let me know and I can track it down.
Thanks everyone
So now I feel like an idiot, I've searched for hours with no luck, and literally seconds after composing this post, I find the nugget of gold I've been searching for.
It appears that our primary file type, PDF, has a known issue with Sharepoint 2010, as shown at the following site.
http://www.sharepointsharon.com/2010/03/sharepoint-2010-and-adobe-pdf/
and further to that, this registry entry setting is required to link it all together
http://www.mossgurus.com/adnan/Lists/Categories/Category.aspx?Name=SharePoint%202010%20--%20Configuration

SharePoint Web Part to View List from Different SharePoint Site

I am working on SharePoint 2010 instance. I want to be able to view list content in the SharePoint site that this list doesn't belong to. My site does not even share the same site collection as the one containing the list. Is this possible without the custom SharePoint solution coding? Thanks.
Here is a workaround:
http://sp2010.pathtosharepoint.com/SharePoint-User-Toolkit/Pages/Cross-Site-List-Snapshot.aspx
This will work across site collections, as long as the source and target pages are in the same domain. It'll work fine if your only purpose is to display the content, not use the context menus.
Other solutions like Data View Web Part or Content Query Web Part won't work across site collections.

Create my site programmatically in Sharepoint 2010

Is it possible to create my site programmatically in SharePoint 2010?
I have added 5 users to AD (Active Directory).
These 5 users are also added in an excel file.
SharePoint 2010 sample site contains a web page where it takes an input as above excel file and on click of a button I want to create 5 my sites of those users specified in excel file with some list, document libraries already created on those my sites.
Is it possible to achieve this functionality in SharePoint 2010? At present I am looking for a code snippet which will use SharePoint 2010 object model and fulfills this requirement.
The UserProfile.CreatePersonalSite method creates a personal site (My Site) for a user.
Various methods and properties of the UserProfile class can then be used to access the site, user's colleagues, quick links, etc.