views:

128

answers:

5

What tips do you have for debugging a WebPart that is not installing? One tip per response.

A: 

One of the most common problems for newbies is probably code access security. A great article for troubleshooting this is Common Security Pitfalls for Web Part Developers by Jan Tielens. It was written for SharePoint 2003 / WSS 2.0 but the same principles apply in SharePoint 2007 / WSS 3.0.

The error is usually something like "A Web Part or Web Form Control on this Web Part Page cannot be displayed or imported because it is not registered on this site as safe."

Alex Angas
A: 

One Quick Solution I can think of seeing your Error message is that,you somewhere in the code have a <%%>. You can try wrapping that part with

<div id="temp" runat="server"> var x= '<% = x.ClientID %>' </div>
Kusek
A: 

Sharepoint does not allow Inline scripting for any content except that in the _layouts folder out of the box. You need to move your inline code block to the code behind.

Colin
A: 

Put a breakpoint in the constructor and debug it. You probably don't want to do anything in the constructor. I think we may have been doing a RunWithElevatedPrivileges there and that was a problem when adding a web part to a page, but not using the web part if it was already on a page.

Kirk Liemohn
A: 

I am using webparts in sharepoint and I didn't find a way for debugging. I just copy the code into another application to debug it

Ahmad Farid