Posts

Showing posts from May, 2014

Sharepoint - Object # has no method 'showModalDialog' in chrome

  Consider the following code: function ShowWelcomeDialog () { var data = {}; var options = { url : "/_layouts/xxxx/xxxxxss.aspx" , title : "xxx xxx" , width : 700 , height : 950 , dialogReturnValueCallback : myDialogCallback , args : JSON . stringify ( data ) }; SP . UI . ModalDialog . showModalDialog ( options ); return false ; }  I have this code for a button click and the modal opens fine in firefox and ie. But it doesn't open in Chrome . It gives the following error in console: Uncaught TypeError:Object # has no method 'showModalDialog'..  Solution: Replace the line: SP . UI . ModalDialog . showModalDialog ( options ); with SP . SOD . execute ( 'sp.ui.dialog.js' , 'SP.UI.ModalDialog.showModalDialog' , options ); StackOverFlow

Sharepoint- Using an Image From formatmap32x32.png in a Ribbon Control

Image
As you know in SharePoint , ribbon button images are coming from a built in image called formatmap32x32.png and formatmap16x16.png which are located at: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\1033\IMAGES So if you are creating custom ribbon buttons, and if you want to use one of the built in button image, then how would you set Image32by32Top and Image32by32Left ? Here is the answer. Get the image from from the above path. Choose the icon image which you would like yo use. As shown below, say the icon which chose is a pie chart as marked with black outline. Count its position from top. its 7. also count its position from left, its 8.  Since the image is 32*32, you would calculate as left=32*8= 256 and Top=224. Now in your Elements.xml use this counts as: Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png" Image32by32Top="-224" Image32by32Left="-256" Use the similar s

Programmatically logging to the Sharepoint ULS

Logging helps one to quickly tracks bugs and evaluate the health of the system under development. SharePoint 2010 allows to log into ULS for our custom code components. Logging in SharePoint 2010 ULS is quite easy. Using just a few lines of code, you can log info from your custom components: [StackOverflow answer ] try { SPSecurity.RunWithElevatedPrivileges(delegate() { SPDiagnosticsService diagSvc = SPDiagnosticsService.Local; diagSvc.WriteTrace(123456, new SPDiagnosticsCategory("Category_Name_Here", TraceSeverity.Monitorable, EventSeverity.Error), TraceSeverity.Monitorable,"{0}:{1}", new object[] { "Method_Name", "Error_Message"}); }); } catch (Exception ex) { } Put above code in some method, and whenever you want to log, just call that method by passing suitable parameters. If you would like to log with your produc