Sharepoint Insight by Namwar Rizvi

Sharepoint Tips, Tricks and inside knowledge from real world experience by Namwar Rizvi

Archive for February, 2009

Launch Office Application from SharePoint Portal Page

Posted by namwar on February 26, 2009


Business Problem:

    One of my client wanted to have links on main portal to launch Microsoft Office key applications i.e Word, Excel, Power Point and Outlook directly by clicking on a link at portal page.

Solution:

I searched the net and find a nice solution here It is a small piece of JavaScript code which you can put in CEWP and use it on your portal page. I added some formatting and relevant icons against the office applications and wraps it up in a webpart dwp file. After importing this web part on your page, you will get something like this:

launchofficeapplication1

You can download the dwp file from here

Advertisements

Posted in Customization, JavaScript, Uncategorized | Tagged: , , , , | 3 Comments »

Add Custom context menu by Javascript in SharePoint

Posted by namwar on February 19, 2009


If you want to add a custom menu item in Document Library’s item context menu just by Javascript without going into the details of  adding any new feature or writing your own assembly then here is a quick trick:

  1. Add a new Content Editor Web Part on your target page
  2. Open the tool pane of the web part
  3. Click Source Editor and add following Javascript code in it
    <script language="javascript">
    function Custom_AddDocLibMenuItems(m, ctx)
    {
      var strDisplayText = "Say Hello World!";
      var strAction = "alert('Hello World')";
      var strImagePath = "";
     
      // Add our new menu item
      CAMOpt(m, strDisplayText, strAction, strImagePath);
     
      // add a separator to the menu
      CAMSep(m);
     
      // false means that the standard menu items should also be rendered
      return false;
    }
    </script>
    
  4. Click Save
  5. Click OK in toolpane to close it
  6. Now open the context menu of an item of the document library and you will see your new menu item in it similar to following

javascript-custom-menu

Please note that this menu item will only be visible on your target not on every page of your document libraries.

Posted in Uncategorized | Tagged: , | Leave a Comment »

Got MCTS Status Today! – Exam 70-542 Done!

Posted by namwar on February 7, 2009


Today, I got the status of MCTS: Microsoft Office SharePoint Server 2007 ― Application Development. This exam focuses on Application Development for Sharepoint Portal Server by utilizing enterprise features. If you are preparing for this exam then I will recommend you the book Professional SharePoint 2007 Development from Wrox publishers.

Main topics covered in this exam are:

  1.  Business Data Catalog (Definition, management etc.)
  2. Data Connection Management, Trusted locations
  3. Audience Management
  4. User Profiles Management
  5. InfoPath Form Server
  6. Records Management
  7. Documents Management
  8. Excel Web Services

You will need to do hands on practice by writing code to make sure you understand object model and context management of API calls.

Good Luck!

Posted in C#, Certification | Tagged: , , | Leave a Comment »

How to fix Cannot run Windows SharePoint Services on this page?

Posted by namwar on February 3, 2009


If you are getting “Cannot run Windows SharePoint Services on this page…” error while trying to upload multiple files in Sharepoint and you are banging your head against the wall then don’t worry you are not alone 🙂 It is the shared pain by many of us facing the legacy errors of FrontPage Server extensions in Sharepoint. This error occurs if you modify Upload.aspx located in layouts folder. First and foremost, do not modify the standard upload.aspx or any other standard file in Sharepoint as it is not supported by Microsoft and your change will be overwritten by any new service pack or hot fix.

So having said that, if you have made a copy of upload.aspx, customized it and trying to use it then you may certainly face this error. Following is the solution to fix it:

  1. Open your copy of upload.aspx and search for 
    <input TYPE="hidden" NAME="_charset_" VALUE="utf-8"><!--webbot bot="FileUpload" endspan i-checksum="45034" -->
  2. Update the following string as follows
    <input TYPE="hidden" NAME="Cmd" VALUE="Save"><!--webbot bot="FileUpload" endspan  -->
  3. Save your file.
  4. Reset IIS
  5. Try to use the file in Sharepoint and Bingo!!!! no more error :):):)

Posted in Uncategorized | Tagged: , , , , | 9 Comments »

Verify your code with SharePoint Dispose Checker Tool

Posted by namwar on February 2, 2009


Today, a new tool  SharePoint Dispose Checker Tool  has been released at MSDN for checking your code against incorrect processing of IDisposable objects like. SPSite and SPWeb. This tool checks your assembly and identify potential problems of not disposing these objects. 

You can download SharePoint Dispose Checker Tool from here

and here is the great article from Paul Andrew (Microsoft Technical Product Manager for the SharePoint Developer Platform) about best practices and how to use this tool.

Posted in Bugs, Debugging, Object Model, Tools | Tagged: , , , , , , | Leave a Comment »