SharePoint Lifesaver

I love reading SmartPart success stories! Matt Ranlett has a nice one: "So I've just wrapped up a quick little demo of how easy it is to code for SharePoint. Since the focus is on easy, and they're not yet 100% sure if we'd be using SharePoint vs a make-your-own ASP.Net 2.0 site, I decided the best way to go is to use the SmartPart and show off how you can write normal old ASP.Net code and still get it to show up in SharePoint. Since we're thinking about an ASP.NET 2.0 site and everyone wants to write ASP.NET 2.0 code, I really had to use the Son of SmartPart, which includes the ability to display 2.0 User Controls and 2.0 Web Parts in SharePoint.  Since this is only a demo, I knocked up a quick little user control that replicates a report we have here.  To get SoSmartPart to "see" a user control, all you have to do is drop the .ascx into a UserControl directory on your SharePoint server.  I did that and PRESTO!  My control shows up in the list of available user controls in the SmartPart toolbox area.  I select the desired control and hit Apply.  BAM - error.

It turns out that you can't use the easy drag/drop data access components in a UC and get it to show up in SharePoint - maybe it has something to do with how the page gets rendered.  Whatever.  Change all those components to ones created dynamically in code (what's that, 5 lines?) and everything started working.  I showed this off to my demo audience and everyone is deeply impressed with how easy everything is.

Then I tell them that we can use ASP Web Parts in SharePoint - which gives us the flexibility to move to a ASP.NET 2.0 site if SharePoint gives us unexpected trouble.  And that the next version of SharePoint will be able to use ASP Web Parts natively without this SmartPart layer...  They love it.  I guess development will start soon."

Thanks Matt! A tip when you use the drag/drop data access controls and components: probably the connection string was will be saved in the web.config. You need to add it manually to the web.config of the SharePoint site. Let me know if you have any problems.

2 Comments

  • Hey Jan,

    I carefully followed your "son of smart part" instructions but I still get:

    "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."

    I have modified my web.config - the web.config on C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\CONFIG

    Is this the proper one to adjust?

    Thanks

  • By "creating dynamically", what exactly do you mean? I'm running into a similar error and having a difficult time fixing it.

    TIA

Comments have been disabled for this content.