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'd like to take an existing web part and add some functionality. Can this be done? I figured out how to download the dwp for the webpart but this does not appear to have any source code in it.

UPDATE

As noted in my comment below, my end goal is to create a page that will be able to search only on columns specific to the content type selected. If someone has suggestions on how to approach this, please let me know.

share|improve this question
1  
Can you provide us name of the webpart, and more information on how do you want to extend it? –  Andrey Markeev Apr 8 '11 at 17:07
    
I wanted to use the Advanced Search Webpart as a base and add some fielded search capabilities. If you know of anything opens ource out there please let me know. I looked around a bit but didn't find anything. –  Abe Miessler Apr 8 '11 at 18:09
add comment

4 Answers

up vote 10 down vote accepted

You can certainly do this for Content Query Web Parts, but beware that some web parts might be sealed.

If you use ILSpy you can view the SharePoint Assemblies to gain understanding of how the OOTB web parts work.

Here's a link to ILSpy: http://wiki.sharpdevelop.net/ilspy.ashx

Here's a link to Andrew Connell's blogpost on extending the Content Query Web Part, as an example: http://www.andrewconnell.com/blog/archive/2008/02/18/Subclassing-the-Content-Query-Web-Part-Adding-Dynamic-Filtering.aspx

share|improve this answer
2  
Your rep is so low James! –  Abe Miessler Apr 8 '11 at 17:08
1  
Tell me about it :( –  James Love Apr 8 '11 at 17:11
1  
+1, i didnt know that reflector was now a paid product and ilspy is its replacement –  djeeg Apr 9 '11 at 9:36
1  
@djeeg Ilspy is one replacement. JetBrains are bringing out a free product called dotPeek but I don't think it's open source. –  Alex Angas May 14 '11 at 1:16
add comment

.dwp and .webpart files contains only definitions of webparts: assembly, class, title, etc. Actual webpart code is in the Microsoft.SharePoint and Mirosoft.Office.Servers assemblies.

share|improve this answer
    
Can you edit this and explain how to view them? Thank you for helping the newbies out. –  trgraglia Nov 3 '11 at 9:45
add comment

So, to extend a webpart, you may be looking at extending the actual class. For this you want to inherit the webpart as a base class.

You can use Reflector to view the source code if you like, though, if possible you should inherit to extend not, just copy&paste code. This allows you to benefit from Microsoft's bug fixes.

EDIT: May 10, 2011

Use ILSpy per James' post now that Reflector costs $$$

share|improve this answer
add comment

Firstly look for the page/webpart/class you are interested in and work out which assembly it is coming from, you can then use a dissasembler tool (like .Net Reflector or ILSpy) to work out what the code is.

In some cases MS will obfuscate the code so you cannot do this, but in most cases it is a really useful way of seeing how MS does something and hence how you can architect a similar or related solution.

share|improve this answer
    
FWIW: ILSpy has a damned good stab at looking at obfuscated code, though you'll probably see lots of goto statements. –  James Love Apr 8 '11 at 20:40
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.