Wednesday, July 14, 2004 9:56 PM Jan Tielens

SmartPart for SharePoint 0.2.0.1 Released!

For those of you who don’t know the SmartPart for SharePoint; a little introduction:A SharePoint web part that can host any ASP.NET user control. Create your web parts by using the VS.NET designer instead of coding everything by hand!

In the last weeks Fons and I have worked on some cool new functionality, you can download the new release (version 0.2.0.1) from the GotDotNet Workspace. To install the SmartPart, execute the MSI Package that’s included. Due to some internal changes, the SmartPart assembly must be deployed to the Global Assembly Cache (GAC), hence if you’re prompted by the installer, choose ‘Yes’. For this release you need to manually alter the web.config file and set the trust level in the system.web section to WSS_Medium (see the readme file for more info). I’m working on this to avoid the manual intervention (already many thanks to Maxim for his help). So, what’s the cool new stuff in this release?

  • Exposing user control properties in the properties toolpane. In the previous versions you needed to implement the IPropertyProvider interface so the SmartPart properties toolpane would display some properties of the user control it contained. These days are over, you can now add the Browsable attribute to every property you want to be exposed. That’s it! By using the Description attribute you can control the caption of the property in the toolpane. Both attributes are in the System.Componentmodel namespace.

  • Dropdown list for easy selection of user controls. In the previous versions the location of the user control needed to entered manually (e.g. “~\UserControls\HelloWorld.ascx”). In the new version you can choose between two web parts: one similar to version 0.1.x (with a textbox as input) and another one with a dropdown list that contains all available user controls. By default the SmartPart List web part will look in the \UserControls directory which user controls are available. If you prefer another location, you can easily change it in the DWP file.

To illustrate how to use the new stuff and to show how easy it is, let’s create a small demo web part. Let’s create a web part that displays the name of the currently logged on user. In Visual Studio, create a new ASP.NET Web Application. Add a new Web User Control to the project, for example UserInfo.ascx. Add a reference to the SmartPart.dll, which is included in the download, and to the Microsoft.SharePoint dll, which you can find on your SharePoint server. Suppose we want to be able to let the user choose a prefix that should appear in front of the user name (e.g. “Current user John Doe”). So we’ll need to create a property Prefix and decorate it with the Browsable attribute. For a good user experience we also add the Description attribute to specify how the property is presented to the user. Add a Label control that will contain the actual text. Because we want to display the user that is currently logged on, we’ll need access to the SharePoint object model. That’s quite easy, just implement the SmartPart.IUserControl interface. Finally we need to add the code to display the prefix and username to the Page_Load function. To finish of, you can add a Description attribute to the class too, so it gets a nice name in the SmartPart dropdown list. The complete code of the user control could look like this:

[System.ComponentModel.Description("Hello World Demo")]
public class UserInfo : System.Web.UI.UserControl, SmartPart.IUserControl
{
            private string _prefix = null;
            protected System.Web.UI.WebControls.Label Label1;
            private Microsoft.SharePoint.SPWeb _web;
            
            [System.ComponentModel.Browsable(true),
             System.ComponentModel.Description("Prefix to display")]
            public string Prefix 
            {          get { return _prefix; }
                        set { _prefix = value; } }
            public Microsoft.SharePoint.SPWeb SPWeb 
            {          get       { return _web; }
                        set       { _web = value;          } }
            private void Page_Load(object sender, System.EventArgs e)
            {
                        Label1.Text = this.Prefix + this.SPWeb.CurrentUser.Name;
            }
            #region Web Form Designer generated code
            // Left out..
            #endregion
}

After you’ve build the project, the deployment can start. You need to copy two files: copy the UserInfo.ascx to the \UserControl folder in the folder that maps to your SharePoint site (e.g. C:\Inetpub\wwwroot\UserControls) and copy the UserInfo.dll to the \Bin folder (e.g. C:\Inetpub\wwwroot\Bin). If the UserControls folder does not exist, you can create it (it’s not a default SharePoint folder). Now drag-and-drop an instance of the SmartPart List web part to a site, and choose the “Hello World Demo” control from the drop down list.

Filed under:

Comments

# re: SmartPart for SharePoint 0.2.0.1 Released!

Wednesday, July 14, 2004 4:16 PM by Christian

GREAT! This is just fantastic stuff!!! :)

# re: SmartPart for SharePoint 0.2.0.1 Released!

Wednesday, July 14, 2004 6:19 PM by Steve

Great stuff. Adding the list is an excellent idea.

Are you taking suggestions for the next iteration? If so, I have one. Currently you can use SmartPart's libraries in the user control to call Sharepoint. This is obviously very useful. The next step from this, I would think, would be the ability to compile a user control, using SmartPart's facilities, that would be exposed to the world as a full-fledged web part. It would have a separate entry in the web part list, its own name on the title, and no SmartPart user control list dropdown.

This would represent what I would think would be a kind of holy grail: The ability to use user controls' full design mode facilities to create a web part.

# Sharepoint : SmartPart for SharePoint 0.2.0.1 Released!

Wednesday, July 14, 2004 7:14 PM by TrackBack

# SmartPart for SharePoint 0.2.0.1 Released!

Thursday, July 15, 2004 1:16 AM by TrackBack

# SmartPart v0.2.0.1 released... and much better than the last version

Thursday, July 15, 2004 4:56 AM by TrackBack

# SmartPart v0.2.0.1 released... and much better than the last version

Thursday, July 15, 2004 4:57 AM by TrackBack

# Migrating Documents into SharePoint, SmartParts, SPS Usage Details, RFID Support

Monday, July 19, 2004 6:43 PM by TrackBack

linked

# re: SmartPart for SharePoint 0.2.0.1 Released!

Monday, July 19, 2004 11:22 PM by Mike-EEE

This is f00kin' awesome! Very rawkin'! I got this goin' no problem. You guys are my fathers!

# re: SmartPart for SharePoint 0.2.0.1 Released!

Wednesday, July 21, 2004 2:29 AM by Jose

Nice additions indeed...but no luck getting them to workk here.

Although the smartpart installs and displays the Usercontrol list correctly, once I add it to the page it refuses to display some of the UserControls that worked perfectly before (with version 0.1). In particular any Usercontrol that connects to Oracle (via OleDB) won't show in the page (appears just blank).

I have <trust level="Full" originUrl="" /> set in the web.config (tried at WSS_Medium with no luck and it broke some things in the proces...)

Any ideas?

JoSE
====

PS.- GREAT job here Jan, great job

# re: SmartPart for SharePoint 0.2.0.1 Released!

Wednesday, July 21, 2004 3:19 AM by Jose

Update: Is not Oracle what is causing problems...all user controls cause them. Even if recompiled with v0.2 of the smartpart.dll. The browsable properties and the list of controls are shown though.

# re: SmartPart for SharePoint 0.2.0.1 Released!

Wednesday, July 21, 2004 8:22 AM by Jose

Final update: Got them working now. The problem was I kept using the UpdateControl function that is no longer valid.

# re: SmartPart for SharePoint 0.2.0.1 Released!

Thursday, July 29, 2004 1:03 PM by Khalnayak

Sure! its one of those wonderful controls. I downloaded and installed on the on all VIRTUAL SERVER on the Sharepoint server. However in any of the SharePoint site, this webpart is not showing up. I just simply ran the latest version 0.2.0.0 MSI package.
What am I missing? I also added the <TRUST> as mentioned in the readme file.

Also do you know where are all these web parts are located on the sharepoint server?
Also I couldn't locate your .DWP file?

Thanks

# re: SmartPart for SharePoint 0.2.0.1 Released!

Tuesday, August 10, 2004 4:51 AM by Darko

I installed as it is saied bu i can't run it in SharedPoint. The error is:
SmartPart 0.2.0.1

Error: unable to load ~\UserControls\UserInfo.ascx
Details: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. (c:\inetpub\wwwroot\UserControls\web.config line 102)

I made the UserCOntrols virtual folder a IIS Application, I add trust tag in web.config but it is still the same.
What is wrong?

# re: SmartPart for SharePoint 0.2.0.1 Released!

Thursday, August 12, 2004 9:07 PM by Pascal (Malaysia)

Hi Jan & Fons, Great stuff .... with 0.2.0.0 only some issues on Sessions but viewstates are working fine but storing dataset may cause some bandwidth overheads. Anyone out there got Sessions to work with Smartparts. Looking forward to tryout 0.2.0.1

#

Wednesday, November 03, 2004 5:26 AM by TrackBack

#

Wednesday, December 08, 2004 4:01 AM by TrackBack

# re: SmartPart for SharePoint 0.2.0.1 Released!

Friday, December 08, 2006 11:30 AM by Rob

How can we expose properties (that are also personalizeable) with Return of SmartPart? I tried the above but didnt work. Thanks.

# re: SmartPart for SharePoint 0.2.0.1 Released!

Tuesday, February 27, 2007 8:04 AM by hani

I am using your smartpart but i have a problem..........!

i am not able to retrieve any sharepoint lists. SpWeb property is turning out to be null.......!

am i doing any mistake ???

# re: SmartPart for SharePoint 0.2.0.1 Released!

Monday, June 25, 2007 7:07 AM by Benjamin

Where can I download an older version of SmartPart. That is SmartPart for SharePoint 2003

# re: SmartPart for SharePoint 0.2.0.1 Released!

Thursday, November 22, 2007 4:44 AM by Latha

Hai

i did everything but i did not get answer... the label  display only blank...

# re: SmartPart for SharePoint 0.2.0.1 Released!

Thursday, November 22, 2007 5:15 AM by Latha

where can i get that smar part 0.2.0.1. that is not available in gotdotnet side

# re: SmartPart for SharePoint 0.2.0.1 Released!

Wednesday, December 12, 2007 9:56 AM by Diesel

# re: SmartPart for SharePoint 0.2.0.1 Released!

Wednesday, December 12, 2007 9:56 AM by Diesel