{"id":670,"date":"2008-09-13T17:54:00","date_gmt":"2008-09-13T22:54:00","guid":{"rendered":"http:\/\/blogs.devhorizon.com\/reza\/?p=670"},"modified":"2009-11-28T13:52:26","modified_gmt":"2009-11-28T18:52:26","slug":"web-part-with-toolbar-part-2","status":"publish","type":"post","link":"https:\/\/blogs.devhorizon.com\/reza\/2008\/09\/13\/web-part-with-toolbar-part-2\/","title":{"rendered":"Web part with Toolbar (Part 2)"},"content":{"rendered":"<p>Sometime in January this year , I wrote a blog post <a href=\"https:\/\/blogs.devhorizon.com\/reza\/?p=491\">here <\/a>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).<\/p>\n<p>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\u00a0 in the following scenarios:<\/p>\n<p>a)\u00a0 In controls deployed to the bin folder and therefore running in partially trusted environments<\/p>\n<p>b) Forms Based Authentication protected sites<\/p>\n<p>And<\/p>\n<p>c) Casting to the base type (ToolBar) in order to call the overloaded functionality.<\/p>\n<p>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 <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/microsoft.sharepoint.webcontrols.repeatedcontrols.aspx\">RepeatedControls<\/a> class, I found another way to achieve this. Read my notes in the community content of this <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/microsoft.sharepoint.webcontrols.repeatedcontrols.aspx\">page<\/a>.<\/p>\n<p><a href=\"https:\/\/blogs.devhorizon.com\/reza\/?attachment_id=671\" rel=\"attachment wp-att-671\" title=\"wpwithtoolbar.png\"><img decoding=\"async\" src=\"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2008\/09\/wpwithtoolbar.png\" alt=\"wpwithtoolbar.png\" \/><\/a><\/p>\n<p>Source Code is available here: <a href=\"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2008\/09\/wpwtoolbar2.rar\" title=\"wpwtoolbar2.rar\">wpwtoolbar2.rar<\/a><\/p>\n<p>More details can be found <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/microsoft.sharepoint.webcontrols.repeatedcontrols.aspx\">here<\/a>.<\/p>\n<p>For this technique used in a much bigger scenario click <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/aa981226.aspx\">here<\/a>.<\/p>\n<p><strong><font color=\"#ff0000\">Update 11\/28\/2010:<\/font><\/strong> Bil Simser further expands this example in his <a href=\"http:\/\/weblogs.asp.net\/bsimser\/default.aspx\">blog<\/a> 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 <a href=\"http:\/\/weblogs.asp.net\/bsimser\/archive\/2009\/11\/28\/cloning-the-sharepoint-toolbar-for-custom-web-parts.aspx\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 , [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[],"class_list":["post-670","post","type-post","status-publish","format-standard","hentry","category-moss-2007"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Web part with Toolbar (Part 2) - Reza Alirezaei&#039;s Blog %<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blogs.devhorizon.com\/reza\/2008\/09\/13\/web-part-with-toolbar-part-2\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Reza Alirezaei\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/09\\\/13\\\/web-part-with-toolbar-part-2\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/09\\\/13\\\/web-part-with-toolbar-part-2\\\/\"},\"author\":{\"name\":\"Reza Alirezaei\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#\\\/schema\\\/person\\\/cdbb24d283697a65951cb4a14e474938\"},\"headline\":\"Web part with Toolbar (Part 2)\",\"datePublished\":\"2008-09-13T22:54:00+00:00\",\"dateModified\":\"2009-11-28T18:52:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/09\\\/13\\\/web-part-with-toolbar-part-2\\\/\"},\"wordCount\":263,\"commentCount\":6,\"image\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/09\\\/13\\\/web-part-with-toolbar-part-2\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/wp-content\\\/uploads\\\/2008\\\/09\\\/wpwithtoolbar.png\",\"articleSection\":[\"MOSS 2007\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/09\\\/13\\\/web-part-with-toolbar-part-2\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/09\\\/13\\\/web-part-with-toolbar-part-2\\\/\",\"url\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/09\\\/13\\\/web-part-with-toolbar-part-2\\\/\",\"name\":\"Web part with Toolbar (Part 2) - Reza Alirezaei's Blog %\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/09\\\/13\\\/web-part-with-toolbar-part-2\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/09\\\/13\\\/web-part-with-toolbar-part-2\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/wp-content\\\/uploads\\\/2008\\\/09\\\/wpwithtoolbar.png\",\"datePublished\":\"2008-09-13T22:54:00+00:00\",\"dateModified\":\"2009-11-28T18:52:26+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#\\\/schema\\\/person\\\/cdbb24d283697a65951cb4a14e474938\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/09\\\/13\\\/web-part-with-toolbar-part-2\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2008\\\/09\\\/13\\\/web-part-with-toolbar-part-2\\\/#primaryimage\",\"url\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/wp-content\\\/uploads\\\/2008\\\/09\\\/wpwithtoolbar.png\",\"contentUrl\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/wp-content\\\/uploads\\\/2008\\\/09\\\/wpwithtoolbar.png\",\"width\":467,\"height\":171},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#website\",\"url\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/\",\"name\":\"Reza Alirezaei's Blog\",\"description\":\"Blogging from the field!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#\\\/schema\\\/person\\\/cdbb24d283697a65951cb4a14e474938\",\"name\":\"Reza Alirezaei\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g\",\"caption\":\"Reza Alirezaei\"},\"url\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/author\\\/rezaa\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Web part with Toolbar (Part 2) - Reza Alirezaei's Blog %","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blogs.devhorizon.com\/reza\/2008\/09\/13\/web-part-with-toolbar-part-2\/","twitter_misc":{"Written by":"Reza Alirezaei","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blogs.devhorizon.com\/reza\/2008\/09\/13\/web-part-with-toolbar-part-2\/#article","isPartOf":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/2008\/09\/13\/web-part-with-toolbar-part-2\/"},"author":{"name":"Reza Alirezaei","@id":"https:\/\/blogs.devhorizon.com\/reza\/#\/schema\/person\/cdbb24d283697a65951cb4a14e474938"},"headline":"Web part with Toolbar (Part 2)","datePublished":"2008-09-13T22:54:00+00:00","dateModified":"2009-11-28T18:52:26+00:00","mainEntityOfPage":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/2008\/09\/13\/web-part-with-toolbar-part-2\/"},"wordCount":263,"commentCount":6,"image":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/2008\/09\/13\/web-part-with-toolbar-part-2\/#primaryimage"},"thumbnailUrl":"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2008\/09\/wpwithtoolbar.png","articleSection":["MOSS 2007"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blogs.devhorizon.com\/reza\/2008\/09\/13\/web-part-with-toolbar-part-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blogs.devhorizon.com\/reza\/2008\/09\/13\/web-part-with-toolbar-part-2\/","url":"https:\/\/blogs.devhorizon.com\/reza\/2008\/09\/13\/web-part-with-toolbar-part-2\/","name":"Web part with Toolbar (Part 2) - Reza Alirezaei's Blog %","isPartOf":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/2008\/09\/13\/web-part-with-toolbar-part-2\/#primaryimage"},"image":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/2008\/09\/13\/web-part-with-toolbar-part-2\/#primaryimage"},"thumbnailUrl":"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2008\/09\/wpwithtoolbar.png","datePublished":"2008-09-13T22:54:00+00:00","dateModified":"2009-11-28T18:52:26+00:00","author":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/#\/schema\/person\/cdbb24d283697a65951cb4a14e474938"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blogs.devhorizon.com\/reza\/2008\/09\/13\/web-part-with-toolbar-part-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blogs.devhorizon.com\/reza\/2008\/09\/13\/web-part-with-toolbar-part-2\/#primaryimage","url":"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2008\/09\/wpwithtoolbar.png","contentUrl":"https:\/\/blogs.devhorizon.com\/reza\/wp-content\/uploads\/2008\/09\/wpwithtoolbar.png","width":467,"height":171},{"@type":"WebSite","@id":"https:\/\/blogs.devhorizon.com\/reza\/#website","url":"https:\/\/blogs.devhorizon.com\/reza\/","name":"Reza Alirezaei's Blog","description":"Blogging from the field!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blogs.devhorizon.com\/reza\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blogs.devhorizon.com\/reza\/#\/schema\/person\/cdbb24d283697a65951cb4a14e474938","name":"Reza Alirezaei","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g","caption":"Reza Alirezaei"},"url":"https:\/\/blogs.devhorizon.com\/reza\/author\/rezaa\/"}]}},"_links":{"self":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/posts\/670","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/comments?post=670"}],"version-history":[{"count":0,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/posts\/670\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/media?parent=670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/categories?post=670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/tags?post=670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}