Home > MOSS 2007 > Web part with Toolbar (Part 2)

Web part with Toolbar (Part 2)

September 13th, 2008 Leave a comment Go to comments

Sometime in January this year , I wrote a blog post here in which I introduced one possible way of adding a Toolbar to a Web part. Although , I am not a big fan on loading user controls dynamically into my Web parts , in order to achieve what I wanted to do , I kind of had to leverage the OOTB toolbar.ascx user control; therefore dynamically load it into the parent control (my Web part).

While the technique in my previous post would work in most of the cases, dynamically loading the control by using LoadControl() method, periodically kept failing on us  in the following scenarios:

a)  In controls deployed to the bin folder and therefore running in partially trusted environments

b) Forms Based Authentication protected sites


c) Casting to the base type (ToolBar) in order to call the overloaded functionality.

I was never able to reproduce the issue , but couple fails was convincing enough for me to look for a better technique to add the toolbar chrome to my Web parts. Well, today while I was documenting RepeatedControls class, I found another way to achieve this. Read my notes in the community content of this page.


Source Code is available here: wpwtoolbar2.rar

More details can be found here.

For this technique used in a much bigger scenario click here.

Update 11/28/2010: Bil Simser further expands this example in his blog using TABLE tags instead of DIVs I initially used. His solution looks more real life and is really cool! Make sure you check his blog post here.

Categories: MOSS 2007 Tags:
  1. No comments yet.