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'm working on Create a Custom Web Part i'm able to do a build and run the new project in debug mode. However, after trying to add the new web part to the site, I get the following error.

"A Web Part or Web Form Control on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe."

I am working on sharepoint 2010

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

This is common error if you eg. changed WebPart name after creation and/or changed its namespace.

Since you are working on SharePoint 2010 and most likely with Visual Studio 2010 in VS project:

  1. Select your custom webpart
  2. Use right click > Properties
  3. In properties windows under SharePoint find Safe Control Entries
  4. Click ... button
  5. Verify your settings (namespace)

Retract your solution and delete your web part from Web Part Gallery (this can be your first step). Rebuild, package and deploy your project.

You don't need to edit your web.config manually!

share|improve this answer
    
okay i fix the namespace issue and now i am getting new error An error occurred while attempting to add the item to the page how do check to see what error is that? or do you want me to open a new question let me know. –  Abu Hamzah Sep 24 '11 at 15:47
    
i posted a new question sharepoint.stackexchange.com/questions/20132/… –  Abu Hamzah Sep 24 '11 at 15:57
    
No need for new question. Did you deleted 'old' webpart from web part gallery? If not retract your solution, delete all 'new' and 'old' webpart definitions from gallery and redeploy. If that doesn't solve your problem you can check SharePoint logs (x:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\LOGS) for more info but most likely then you have some specific error in your custom webpart. You need to run in debug mode and check in VS for errors when adding webpart. –  Vedran Rasol Sep 24 '11 at 16:21
    
Also be sure to read: Best Practices for Developing Web Parts for SharePoint Products and Technologies. It's a bit old but error handling section I linked still applies. –  Vedran Rasol Sep 24 '11 at 16:29
1  
i just delete the old web part by going to Site Actions>>Site Settings>>>>Gallary (Web Parts) check my web parts and "Delete Document" –  Abu Hamzah Sep 24 '11 at 16:29
show 2 more comments

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.