14 December, 2005

Using IE WebControls in SharePoint

The Internet Explorer WebControls is an awesome collection of ASP.NET server controls that gives you a solution for four UI elements: TreeView, Toolbar, TabStrip and MultiPage.

You can use these in your SharePoint web parts or user controls (loaded through SmartPart). However, there are a few things you need to be aware of in order to get it to work under SharePoint.

SharePoint does not like unsigned code, so you need to rebuild the assembly with a strong name. Then deploy the assembly to the GAC or another trusted area. The JavaScript used in the controls is located in the folder '/webctrl_client/' under your IIS root directory. You need to add this path as an excluded path in SharePoint.

The treeview uses its own font and font size specified by the variables 'L_fontSize_Text' and 'L_fontName_Text' in the file 'treeview.htc' under '/webctrl_client/1_0/'. You can change this to suit your needs or preferably leave them as empty strings to use whatever is specified in the SharePoint stylesheets.

9 comments:

Anonymous said...

I have Created a strongly named assembly, copied all the elements of c:\program files\ie web Controls\build\runtime to inetpub\wwwroot\webctrl_client\1_0,and excluded the path.
After Creating the webpart with anyone of the Control like Treeview, I assigned keypair, and made an entry into web.config file.
When i am trying to put the webpart on the portal i am getting an error. Can u please help what mistake i am doing here. I am following the Advanced Sharepoint Solution Services by Scot p. Hillier.

Kristian Kalsing said...

Did you install the strongly named assembly in the GAC?

Anonymous said...

yes i have generated strongly named assembly.
And copied the dll to the c:\inetpub\wwwroot\bin

Anonymous said...

And also copied the assembly in GAC(c:\windows\assembly)

Kristian Kalsing said...

Yes, it needs to be in the GAC. If you only copy it to the bin folder of your web server, you would also need to write a custom policy file to grant it the right permissions. But deploying it to the GAC should be good enough.
And you added the 'webctrl_client' folder (not 'webctrl_client\1_0') to the excluded paths of the your virtual server in SharePoint?
I can't think of anything else. Maybe go through all the steps again to make sure you haven't missed anything.

Anonymous said...

I have done all the steps which you said. But still it is giving me the same error. If possible can you please explain me how to generate strongly named assembly.
Actually i generated the strongly named assembly using 'Web Control Library' Project from VS 2003. Added all the sources files from '\program files\IE web Controls\src and 'src\Resources', and .bmp and .resources from 'src\design'(created folders for resources and design fies). Then added the references System.Data.dll, System.Design.dll, System.Windows.Form.dll, and System.Xml.dll. Then Set the Solution Configuration to Release.
Generated the keypair and added the keypair in version.cs. Build the assembly.
These are the steps i followed.
Is i am making any mistake anywhere. If so, Can u please correct that.
I am thankfull to you for your help.

Marcus Rosen said...

Try removing the reference to System.Windows.Forms and System.Design ?!?

You need to build the TreeView Control assembly as a stand alone entity in the GAC.

From your post it sounds like you are trying to add the Source files of the TreeView controls project to your web control project?? This is not the way to go.

To build a web control (.ascx) that uses the treeview control you need to the following:

1) Generate a Key to sign with:
sn.exe -k keys.snk

2) Add an AssemblyKeyFile Attribute to the TreeView control assembly (usually done in the AssemblyInfo file, which is part of the Project that you download).

3) Build this assembly and register in the GAC (using drag and drop or GACUTIL.EXE)

4) Build your web control. You need to add the web controls dll to the visual studio.Net tool box to be able to use them. Once this is done you should be able to drag and drop the treeview control to the design surface.

5) Update the web.config file to allow SharePoint to load the TreeViews control from the GAC.

6) Do the other usual things you need to do for SmartPart...

Marcus

Anonymous said...

how to create a treeview in web part

Anonymous said...

i am new to sharepoint concepts
i want to create an explorer view in sharepoints please help me regarding this
thanks in advance