Wednesday, April 18, 2012

FIX: Secure VPN Connection terminated locally by the Client Reason 442: Failed to enable Virtual Adapter


  1. Press Windows and R key to open Run window, type inservices.msc
  2. Stop the Cisco Systems … service
  3. Stop the Internet Connection Sharing (ICS) service
  4. Right click on ICS service and choose Properties. Then changeStartup type to Disabled or Manual
    I prefer to stop this service until you finish working on the VPN 
  5. Start Cisco Systems … service
  6. Done. Now create a VPN connection, error 442 no more !

Wednesday, April 11, 2012

Adding WSP Solution to SharePoint 2010 using Power Shell


1.    Open SharePoint 2010 Management Shell write the folowing command for each wsp file in the “WSP Solutions” folder ()
-          Add-SpSolution “WSP File Path” .
2.    Open the SharePoint 2010 Central Administration
3.    Click on the System Settings èManage Farm Solutions èclick on each WSP File and click on deploye link

Sunday, April 8, 2012

Recommendation 
try to use extended query web part in order to expose the  XSLT over the share point list

this link for shows some good libraries which are good for the share point developers
http://www.purecoding.net/CodeZone/SharePoint/tabid/67/ItemID/19/Default.aspx

Thursday, April 5, 2012

a great SharePoint blog

http://www.ahmadkhalaf.com/ahmadkhalaf/blog/?p=90
minimal master page in SharePoint
and here is a very good article


<%@ Master language=”C#” %>
http://www.w3.org/TR/html4/loose.dtd“>
<%@ Import Namespace=”Microsoft.SharePoint” %>
<%@ Register Tagprefix=”SharePoint” Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”Utilities” Namespace=”Microsoft.SharePoint.Utilities” Assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”WebPartPages” Namespace=”Microsoft.SharePoint.WebPartPages” Assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register TagPrefix=”wssuc” TagName=”Welcome” src=”~/_controltemplates/Welcome.ascx” %>
<%@ Register TagPrefix=”wssuc” TagName=”DesignModeConsole” src=”~/_controltemplates/DesignModeConsole.ascx” %>
” runat=”server” xmlns:o=”urn:schemas-microsoft-com:office:office” __expr-val-dir=”ltr”>
<%– The head section includes a content placeholder for the page title and links to CSS and JavaScript files that run on the server. –%>
 </p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 12px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; line-height: 21px; color: rgb(109, 110, 110); font-family: Arial, Verdana, sans-serif; ">  <asp:ContentPlaceHolder id=”PlaceHolderPageTitle” runat=”server” /></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 12px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; line-height: 21px; color: rgb(109, 110, 110); font-family: Arial, Verdana, sans-serif; "> 

” id=”SiteActionsMenuMain” PrefixHtml=”<div><div>” SuffixHtml=”</div></div>” MenuNotVisibleHtml=”&nbsp;”>
            
            
              FeatureScope=”Site”
              Location=”Microsoft.SharePoint.StandardMenu”
              GroupId=”SiteActions”
              UseShortId=”true”
              >
             
               Text=”<%$Resources:wss,viewlsts_pagetitle_create%>”
               Description=”<%$Resources:wss,siteactions_createdescription%>”
               ImageUrl=”/_layouts/images/Actionscreate.gif”
               MenuGroupId=”100″
               Sequence=”100″
               UseShortId=”true”
               ClientOnClickNavigateUrl=”~site/_layouts/create.aspx”
               PermissionsString=”ManageLists, ManageSubwebs”
               PermissionMode=”Any” />
             
               Text=”<%$Resources:wss,siteactions_editpage%>”
               Description=”<%$Resources:wss,siteactions_editpagedescription%>”
               ImageUrl=”/_layouts/images/ActionsEditPage.gif”
               MenuGroupId=”100″
               Sequence=”200″
               ClientOnClickNavigateUrl=”javascript:MSOLayout_ChangeLayoutMode(false);”
               />
             
               Text=”<%$Resources:wss,settings_pagetitle%>”
               Description=”<%$Resources:wss,siteactions_sitesettingsdescription%>”
               ImageUrl=”/_layouts/images/ActionsSettings.gif”
               MenuGroupId=”100″
               Sequence=”300″
               UseShortId=”true”
               ClientOnClickNavigateUrl=”~site/_layouts/settings.aspx”
               PermissionsString=”EnumeratePermissions,ManageWeb,ManageSubwebs,AddAndCustomizePages,ApplyThemeAndBorder,ManageAlerts,ManageLists,ViewUsageData”
               PermissionMode=”Any” />
            
            
           

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 



Wednesday, April 4, 2012

Upload Document To Document Library with PUT method




Following is a utility function which you can use to upload a file programmatically in SharePoint document library. It has two parameters. First is the source file path and second is the target document library path. 
Following is an example call to this function:
UploadFileToDocumentLibrary(@”C:\test.txt”@”http://home-vs/Shared Documents/textfile.txt”);
and here is the function
    public static bool UploadFileToDocumentLibrary(string sourceFilePath, string targetDocumentLibraryPath)
    {
        //Flag to indicate whether file was uploaded successfuly or not
        bool isUploaded = true;
        try
        {
            // Create a PUT Web request to upload the file.
            WebRequest request = WebRequest.Create(targetDocumentLibraryPath);

            //Set credentials of the current security context
            request.Credentials = CredentialCache.DefaultCredentials;
            request.Method = “PUT”;

            // Create buffer to transfer file
            byte[] fileBuffer = new byte[1024];

            // Write the contents of the local file to the request stream.
            using (Stream stream = request.GetRequestStream())
            {
                //Load the content from local file to stream
                using (FileStream fsWorkbook = File.Open(sourceFilePath, FileMode.Open, FileAccess.Read))
                {
                    //Get the start point
                    int startBuffer = fsWorkbook.Read(fileBuffer, 0, fileBuffer.Length);
                    for (int i = startBuffer; i > 0; i = fsWorkbook.Read(fileBuffer, 0, fileBuffer.Length))
                    {
                        stream.Write(fileBuffer, 0, i);
                    }

                }
            }

            // Perform the PUT request
            WebResponse response = request.GetResponse();

            //Close response
            response.Close();
        }
        catch (Exception ex)
        {
            //Set the flag to indiacte failure in uploading
            isUploaded = false;
        }

        //Return the final upload status
        return isUploaded;
    }

Tuesday, April 3, 2012

SharePoint Generic Webpart


public class BEATGenericWebPart : WebPart
{
    private string m_controlName;

    private string m_controlTemplatesPath;

    private string m_Folder;

    [Personalizable(PersonalizationScope.Shared)]
    [WebBrowsable(true)]
    [WebDisplayName("Name of User Control")]
    public string ControlName
    {
        get
        {
            return this.m_controlName;
        }
        set
        {
            this.m_controlName = value;
        }
    }

    [Personalizable(PersonalizationScope.Shared)]
    [WebBrowsable(true)]
    [WebDisplayName("Control Templates Path")]
    public string ControlTemplatesPath
    {
        get
        {
            return this.m_controlTemplatesPath;
        }
        set
        {
            this.m_controlTemplatesPath = value;
        }
    }

    [WebDisplayName("User Controls Folder")]
    [Personalizable(PersonalizationScope.Shared)]
    [WebBrowsable(true)]
    public string Folder
    {
        get
        {
            return this.m_Folder;
        }
        set
        {
            this.m_Folder = value;
        }
    }

    public BEATGenericWebPart()
    {
        this.m_controlTemplatesPath = string.Empty;
        this.m_Folder = string.Empty;
        this.m_controlName = string.Empty;
    }

    protected override void CreateChildControls()
    {
        try
        {
            string str = string.Format("{0}{1}{2}", this.m_controlTemplatesPath, this.m_Folder, this.m_controlName);
            Control control = this.Page.LoadControl(str);
            this.Controls.Add(control);
        }
        catch (Exception exception1)
        {
            Exception exception = exception1;
            Label label = new Label();
            label.Text = exception.Message;
            this.Controls.Add(label);
        }
    }

    protected override void RenderContents(HtmlTextWriter writer)
    {
        this.EnsureChildControls();
        base.RenderContents(writer);
    }
}