Posts

How to Convert Image to Byte Array or Bitmap

This time I present code that can help you work with images ( System.Drawing ). I showed how to convert Image to Byte Array and how to convert Image to Bitmap . here is the code: /// <summary> /// Image Converter from Image to byte array /// </summary> /// <param name="img">Image</param> /// <returns>byte</returns> public static byte [] ImageToByte( Image img) {      ImageConverter converter = new ImageConverter();      return ( byte [])converter.ConvertTo(img, typeof ( byte [])); } /// <summary> /// Image Converter from Image to Bitmap /// </summary> /// <param name="img"></param> /// <returns></returns> public static Bitmap ImageToBitmap( Image img) {      ImageConverter converter = new ImageConverter();      return ( Bitmap )converter.ConvertTo(img, typeof ( Bitmap )); } Yours, Roi

Whether the current user belongs to a SharePoint group policy

This time I will present the work Code which provides the current user has identification.      #region Permission      /// <summary>      /// return true is the CurrentUser has Permission in CurrentWeb      /// groupNames is the groups that split by ';'.      /// </summary>      /// <param name="groupNames"></param>      /// <returns></returns>      public static bool IsUserHasPermission( string groupNames)     {       SPUser user = SPContext.Current.Web.CurrentUser;       SPWeb web = SPContext.Current.Web;        return IsUserHasPermission(groupNames,web,user);     }      /// <summary>      /// re...

Error occurred in deployment step 'Recycle IIS Application Pool': The local SharePoint server is not available. Check that the server is running and connected to the SharePoint farm

Image
Did you receive the following error when you tried to compile a project of SharePoint 2010? Error occurred in deployment step 'Recycle IIS Application Pool': The local SharePoint server is not available. Check that the server is running and connected to the SharePoint farm. So - the solution is simple You should be Full Permission on the SharePoint Farm - including a data base (DB owner). After it is completed - open the visual studio as administrator. Cheers, Roi Kolbinger

Date and Time in JavaScript

Image
And this time I will present a snippet of code in javascript that shows the date and time. You can put it wherever you like - in nearly every segment SharePoint Designer or in the Content Editor WebPart. The JS code shows Date and Time <!-- Clock --> < script language ="JavaScript"> var clockID = 0; function UpdateClock() {    if (clockID) {       clearTimeout(clockID);       clockID   = 0;    }    var tDate = new Date();    var roiClock = window.document.getElementById( "roiClock" );    roiClock.innerHTML = ""     + tDate.toLocaleDateString()     + "&nbsp;&nbsp;&nbsp;&nbsp;"      + tDate.getHoursTwoDigits() + ":"      + tDate.getMinutesTwoDigits()    clockID = setTimeout( "UpdateClock()" , 6000); } function StartClock() {    clock...

Override the render function of the SharePoint content editor WebPart

Image
Had you come across on Bug of the SharePoint Content Editor WebPart So there is interesting problem If using external links and internal links – you will get the bug An example to the bug: Try This - Internal links, external links and internal links again What we get is the first two links work correctly, but the third link will link us to link the internal server name we have created the site. This is big bug for CEWP. Hope you understood the bug. How do we solve it? You can not inherit the WebPart - then shall we do? Built Control Adapter performs render the code. Create a small project in Visual Studio that contains the following code using  System; using  System.Collections.Generic; using  System.IO; using  System.Text; using  System.Web.UI; using  Microsoft.SharePoint; using  Microsoft.SharePoint.Administration; namespace  Roi.Moss.ControlAdapter.ContentEditorWebPart {   public   class   Conte...

There was an exception running the extensions specified in the config file. ---> Maximum request length exceeded.

Image
Have you ever encountered the following message when you try to transfer large data in web service ? There was an exception running the extensions specified in the config file. ---> Maximum request length exceeded. :) All you need to do is: Access to the remote server where the is WebService. Go to the web.config and set the tag httpRuntime the following code on the " system.web " tag. < system.web >   < httpRuntime executionTimeout = " 999999 " maxRequestLength = " 51200 " > ... Roi

How to Create a validation to a list form for "Attach File" for SharePoint

Image
Sometimes the little code - works! How to do on MOSS 2007 list form a requirement to the attach field ?   Let build up a validation in JavaScript The following JS code do it perfectly. All you need is access to the SharePoint Designer . Edit the form ( NewForm.aspx or EditForm.aspx ). Find a good place to insert the code in the list form, And Copy-Paste the code: < script   type ="text/javascript"   language ="javascript> function  PreSaveItem() {   var  elm = document.getElementById( "idAttachmentsTable" );   if  (elm ==  null  || elm.rows.length == 0)   {     alert( "Please attach a document to the request" );     return   false ;   }   if  ( "function"  ==  typeof  (PreSaveAction))   {     return  PreSaveAction();   }   ...