There are various web part events in the life-cycle. The following would shed some light to these events and help us to choose these events correctly based on the needs
OnPreRender- It is called logically called before Render event of the ASP.NET page. This is the last opportunity for us to affect the rendering behavior of the web part page. Things like changes to the viewstate properties can be done logically in the OnPreRender event. Moreover the OnPreRender event is called logically after the events EnsureChildControls and CreateChildControls
CreateChildControls:
If we need to render the ASP.NET web server controls (ike button, text box etc) in the web part, this event needs to be overridden. Logically we can add web controls and wire the events to it
Render
This event is used logically to control the rendering behavior of the web part. There is already a default implementation of Render method. We need not always override Render method for certain cases like CreateChildControls method having the logic to add controls. Render method can also be used to render html stream (directly) and ASP.NET web server controls
Render Control
This method can be called inside the overridden Render method to render the ASP.NET web server controls like button, textbox etc...
Render Contents
RenderContents gives power to render the html streams directly inside the overridden Render method. The RenderContents should be preceded by RenderBeginTag and the RenderContents should be followed RenderEndTag
Scenario
There is a server running SharePointPortalServer 2003. It has many web applications running SharePoint sites. How to remove SharePoint from just one web application?
Solution
The unextend functionality of stsadm.exe can be used to remove SharePoint from the selected IIS web application
stsadm.exe -o unextendvs -url <url> -deletecontent
http://technet2.microsoft.com/Office/en-us/library/f057d1e5-f8b7-4c92-bb98-3f983df2a2d11033.mspx?mfr=true
http://technet2.microsoft.com/windowsserver/WSS/en/library/c3314243-a583-4e62-a49a-baf706da97401033.mspx
If SharePoint needs to be completely removed from the server, the SharePoint server needs to be un-installed and the other components like indexes, database also need to be removed
Scenario:-
There is a Link web part and a Page viewer web part on the web part page. The requirement is that, whenever a user clicks on a particular link inside Link Web Part it should automatically render the corresponding page inside the page viewer web part.
Challenges:-
By default the page viewer web part does not support connections.
Solution:-
The solution is to create a page viewer web part that accepts the url as the connectable parameter. There is an interesting post by Todd Baginski about creating a connectable Page Viewer Web Part
http://www.sharepointblogs.com/tbaginski/archive/2007/08/16/connected-page-viewer-web-part.aspx
Even though the code-sample mentioned in the above link is for SPS 2003, we need to do code changes if we are developing it for WSS 3.0 / MOSS 2007. Probably if we are developing the web part as "SharePoint web part" the code changes we'd be making is less, compared to developing it as "ASP.NET" web parts.
I'd try this developing it for WSS 3.0/ MOSS 2007 and share my experiences
Scenario
XMLFormView web part is used to render the Infopath browser forms. The XmlFormView web part cannot add to the web part page. It throws error message "The form has been closed"
Cause
This problem can be due to several reasons. They are listed below
- The location ".xsn" might be hard-coded with an incorrect location
- The XML FormView web part might be deployed to bin without sufficient code-access permissions
Solution
This can be solved by the following steps
- Not to hard-code the .xsn location in the code-behind of XmlFormView web part
- Provide the proper code-access permissions to the web part
Imports System.Security
<Assembly: AllowPartiallyTrustedCallers()>
After adding the web part to the web part page, provide the correct location of ".xsn" to the web part property
There is a requirement to index and search PDF documents inside MOSS 2007. The first thing that comes to my mind is "IFilters". Then I need to choose between the V6 and V8.1 of the IFilters. The advantage of Acrobat Reader V8.1 reader is that it has IFilters inside.
I did not choose V8.1 . Because I don't have special requirement to deal with WDS search. So I've chosen IFilters V6. Here are steps that I followed to install the pdf IFilters
a)Download Adobe PDF IFilters 6.0
b)Start -->Run-->> Services.msc and stop the IIS Admin service. The reason we need to do this is, the IFilters configuration needs an update to DOCICON.XML.
c)Run the IFilters installer on the Indexing Server
d) Download the pdf icon image
of size 17X17 from the following location and save it as "icpdf.gif" somewhere to the local hard disk
http://www.adobe.com/misc/linking.html
d)Copy the icpdf.gif to the following location
"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Images"
e) Go the C:\Program Files\Common Files\Microsoft Shared\Web server extensions\12\Template\Xml\
f) Edit the DOCICON.XML by adding the following entry
<Mapping Key="pdf" Value="icpdf.gif"/>
g) Perform an IIS RESET
h) Go to Search Settings under Central Administration and add the pdf as the new file type
g) Perform the crawl again
Now MOSS is supposed to search pdf documents properly. This is what said in so many Articles and Blogs. It did not work for me that easily. After some analysis, I've learnt that I need to apply a Microsoft Hot fix to make this work for MOSS 2007. The Microsoft Hot fix mentions the following steps to be performed to make the pdf search work for MOSS 2007
1. Add the following registry entry, and then set the registry entry value to pdf:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Search\Applications\<GUID>\Gather\Search\Extensions\ExtensionList\38
To do this, follow these steps: a. Click Start, click Run, type regedit, and then click OK.
b. Locate and then click the following registry subkey:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Search\Applications\GUID\Gather\Search\Extensions\ExtensionList
c. On the Edit menu, point to New, and then click String Value.
d. Type 38, and then press ENTER.
e. Right-click the registry entry that you created, and then click Modify.
f. In the Value data box, type pdf, and then click OK.
2. Verify that the following two registry subkeys are present and that they contain the appropriate values.
Note these registry subkeys and the values that they contain are created when you installed the Adobe PDF IFilter on the server.
• HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Search\Setup\ContentIndexCommon\Filters\Extension\.pdf
This registry subkey must contain the following registry entry:• Name: Default
Type: REG_MULTI_SZ
Data: {4C904448-74A9-11D0-AF6E-00C04FD8DC02}
- HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Search\Setup\Filters\.pdf
This registry subkey must contain the following registry entries:
• Name: Default
Type: REG_SZ
Data: (value not set)
• Name: Extension
Type: REG_SZ
Data: pdf
• Name: FileTypeBucket
Type: REG_DWORD
Data: 0x00000001 (1)
• Name: MimeTypes
Type: REG_SZ
Data: application/pdf
3. Upload the PDF documents to the Windows SharePoint Services 3.0 Web site.
a. Stop and then start the Windows SharePoint Services Search service. To do this, follow these steps:a. Click Start, click Run, type cmd, and then click OK.
b. Stop the Windows SharePoint Services Search service. To do this, type net stop spsearch at the command prompt, and then press ENTER.
c. Start the Windows SharePoint Services Search service. To do this, type net start spsearch at the command prompt, and then press ENTER.
d. Type exit to exit the command prompt.
Now MOSS is ready to search pdf documents
Scenario
I'm more into SharePoint development these days, especially the development of custom web parts. I felt like I need to remember quite a bit of command line tools for SharePoint development, especially sn.exe which is more commonly used in web part development. I was looking for an option in Visual Studio to do this job.
Solution
After a bit of search I’ve found that this can be achieved by leveraging External Tools option in Visual Studio
In Visual Studio 2005 --> Tools -----> External Tools
Click Add button

Enter the Title 'Fetch Public Key'
Under Command, choose the sn.exe from C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin

In the Arguments set the value as -Tp "$(TargetPath)" T - retrieves the public key token of the assembly, p - Blob of the public key $(TargetPath) - location where the VS.NET created the assemblySelect 'Use Output Window' optionClick Ok and Apply.Now, we can fetch the public key of the project (assembly)

Scenario
We tried to customize the the master page of a SharePoint site (Team Site). The intent was to add banner image and icon to the master page. We edited the master page using SharePoint Designer 2007. We dragged and dropped the image to the master page and aligned it. We saved all the changes. Then, we refreshed the site. The changes were reflected. We saved this customized site as the site template ".stp" and shipped it Whenever someone creates a site using this ".stp", the images are not rendered in their newly created site using this site template
Cause of the Problem
After analysis we found that, the images in the master pages were not picking the URL relative to the newly created site. It's picking the URL relative to old site, from which the template was created
<img alt="" src="/Sites/old site/_catalogs/masterpage/testimage.gif" width="974" height="69"></td>
If we set the relative URL in both the Notepad and the SharePoint Designer, after the save of master page it's always not reflecting the relative URL
Resolution
We replaced the image tag with ASP.NET Image server control
<asp:Image ImageUrl="./../../images/testimage.gif" runat="server"/>
This made it to work. Whenever we need to disribute a sharepoint site template with custom master pages, it's better to use ASP.NET Image control instead of <img> tags