Monthly Archives: June 2011

How to open new modal window in Silverlight from Telerik RadMenu

A coleague of mine asked me a question about opening modal window from RadMenu. Normally you will open some .xaml that is specified in Tag property. But how to execute some code when clicked on item in menu? To not specify a Tag is the obvious and first, what will come to your mind, but it isn’t the right one, unfortunatelly. 🙂 Going down this path, although the code in onclick eventhandler will be executed, you will be rewarded with nice exception : Value cannot be null. Parameter name : uriString.

But don’t fear, there is hope (and solution :)) and it’s not that hard.

  1. Don’t specify Tag in XAML parkup,
  2. Write OnClick eventhandler of the RadMenuItem and execute whatever code you need (instantiate modal window for example),
  3. Set Handled property of EventArgs in OnClick eventhandler to true.

Setting Handled to true means that further processing of event stops. And that’s exactly what we need. 🙂

Events in Silverlight are interesting and important thing to understand.

You can find more information about them here :

http://www.silverlightshow.net/items/Routed-Events-in-Silverlight.aspx

and here

http://msdn.microsoft.com/en-us/library/cc189018%28v=vs.95%29.aspx

How to hide chrome (ribbon bar, left menu and add new item) in Microsoft SharePoint MOSS 2010 conditionally

With migration to SharePoint 2010 at our company, I have been given task to fix my old solution of hiding the chrome (menu and ribbon on 2010) that I described in my old blog post here :

http://blog.aspnet.sk/rostacik/archive/2009/04/17/how-to-hide-chrome-on-sharepoint-list-wss-and-moss.aspx

that was broken when migrated. Something changed, obviously.

At first, what we need to achieve :

We are using MOSS document library to store files, that are attached via key to some entity in CRM (this funcionality is now built in in CRM 2011). We need to display library “untouched” when accessed from normal URL but when accessed from IFRAME, CRM list should detect this and hide his chrome what we get more space and users see only what the need to see.

So, the solution is simple. You need to :

  1. Insert content editor webpart to the desired list. This built in webpart can insert desired text as markup into the list (js, css, anything you need).
  2. Click on the place where you can edit/insert text into the webpart and in the ribbon you should be able to edit the HTML of the webpart. This will cause modal window to open and you can edit markup that will be inserted.
  3. Because we need some logic when to hide chrome and when not, I’m inserting JS here, but you can insert the CSS here, but be aware that this will hide controls that you need to change something in the list. This could be fixed with tool like FireBug or IE Development Tools and hacking CSS properties in memory (same approach I used to find out what to write in the CSS to hide chrome).
    The JS I used to dynamically insert my custom CSS file (no changes from MOSS 2007). Please note the http://yourserver/yourcssfile.css – this must be changed to link where you can access the CSS file, for example documents library or so and every user must be able to access this file as well. :
  4. Upload this CSS somewhere, where you can access it (as stated in previous point) :
    #s4-ribbonrow, .ms-cui-topBar2, .s4-notdlg, .s4-pr s4-ribbonrowhidetitle, .s4-notdlg noindex, #ms-cui-ribbonTopBars, #s4-titlerow, #s4-pr s4-notdlg s4-titlerowhidetitle, #s4-leftpanel-content {display:none !important;}
    .s4-ca{margin-left:0px !important; margin-right:0px !important;}
    table#Hero-WPQ2 {display:none !important;}
    This will hide what we need to hide, you maybe want to hide something else.

So, that’s it. I’m attaching both files so you don’t need to copy&paste both things. Smile

Enjoy and if you have any questions, just mail me / ask me in the discussion.

hide-chome-moss2010

hide-chrome-moss2010

Similar blog posts :

http://geekswithblogs.net/venkatx5/archive/2010/11/17/how-to-hide-top-bar-ribbon-quick-launch-in-sharepoint.aspx

http://littletalk.wordpress.com/2011/06/02/hide-default-controls-in-sharepoint-2010/