Skip to main content

Posts

Showing posts from April, 2011

Code for language translation

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML xmlns:o> <HEAD>   <TITLE>Gujarati translation-Ravishankar</TITLE>    <script type="text/javascript" src=" http://www.google.com/jsapi"></script >       <script type="text/javascript">       google.load("elements", "1", {       packages: "transliteration"        });       function onLoad() {      var options = {       sourceLanguage:        google.elements.transliteration.LanguageCode.ENGLISH,       destinationLanguage:        google.elements.transliteration.LanguageCode.GUJARATI,       shortcutKey: 'ctrl+g',       transliterationEnabled: true      };      var control =       new google.elements.transliteration.TransliterationControl(options);      control.makeTransliteratable(['transliterateTextarea']);       }       google.setOnLoadCallback(onLoad);      </script>

Create a Web Part Page with a Web Part in Sharepoint 2010

Source code from codeplex In this blog I am going to explain how to create a web part page along with a web part. After using this feature, we just need to activate the feature; the rest will complete automatically. Steps for creating the functionality: Step 1: Create a project with Farm-Based solution: Step 2: Add a new item as webpart: Step 3: Add feature event receiver class, your solution should look like the following: Step 4: Add your logic to the web part: 01 [ToolboxItemAttribute( false )] 02 public class CustomWebPart : WebPart 03 { 04 protected override void CreateChildControls() 05 { 06 LiteralControl lt = new LiteralControl(); 07 lt.Text = "This webpart automatically added with page" ; 08 this .Controls.Add(lt); 09 } 10 } Step 5: You need to provide logic in the feature Reciever class. Find the attached file to see the source code. Step 6: Build, deploy and activate the feature. Step 7: Go to Page library ( S

How to create Sandbox solution with full trust Proxy

Download Files: CustomSBFullTrust.zip In this article I am explaining the step by step procedure to create a sandbox solution with full trust proxy. Before starting I am assuming you are aware of the sandbox limitations. Full trust solution is providing sandbox solution to work in a full environment. In short this is the way to achieve farm based solution functionality in a Sandbox. Namespace Required: using Microsoft.SharePoint.UserCode; using Microsoft.SharePoint.Security; using System.Security.Permissions; using Microsoft.SharePoint; using Microsoft.SharePoint.Publishing;

SharePoint Language translator web part using Sandbox

Download Files: Ravishankar.TranslatorWebPart.zip In this article we will see how to create a language translator webpart using sandbox. If you read my previous articles on language translator then it will be easy for you to understand. Before writing this article I also searched much but I didn't find a solution/web part that explains the procedure for creating a language translator in sandbox solution. As we know the limitation of a sandbox so you fill find very rare article on Language translation using sandbox web part.

How to create Publishing Page based on page layout in sharepoint2010

Hi Friends, This blog will help you when you need to create pages in based on page layout.You just need to use the below common method. private void CreatePublishingPage(string absoulteUrl, string pageName, string pageLayoutName, bool isLandingPage) { using (SPSite Osite = new SPSite(absoulteUrl)) { using (SPWeb oWeb = Osite.OpenWeb()) { string fullPageUrl = string.Empty; PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(oWeb); /* Get the publishing web page collection list. */ PublishingPageCollection publishingPageCollection = publishingWeb.GetPublishingPages(); //GetPageLayoutName(application); if (!string.IsNullOrEmpty(pageLayoutName)) { /* Search for the page layout for creating the new page */ List layouts = new List (publishingWeb.GetAvailablePageLayouts()); PageLayout pageLayout = layouts.Find( delegate(PageLayout l) { return l.Name.Equals(pageLayoutName, StringComparison.CurrentCultureIgnoreCase); }); /*page layout exists*/ if (pageLayout

How to create a language translator using Google's API and JavaScript

Download Files: LanguagetranslatorusinggoogleAPI.zip In my previous article , I only explained how to create a language translator with http request. In this article I am going to explain how to create a language translator using GToogle API and JavaScript. As a Sharepoint developer I am expecting whatever code I am trying to work everywhere and in all environments. So I found JavaScript is the best way to write the code. The Google API is has more options compared to Microsoft's translator and we can use this script wherever we want. I tested the code in creating the sharepoint webpart and an ASP.Net application. The following is the screenshot of my application: If we take a close look at my application you can find, I have created a translator in three ways: Using HTTP handler (Already explained in my previous article) Using SOAP method Using JavaScript with Google API I am going to explain one in this article below. You can find all three ways in my solution that I ha

Installation and configuration for FxCop tool

Today I am going to explain about the installation and configuration for fxcop tool. Description about tool: FxCop is a tool that performs static code analysis of .NET code. It provides hundreds of rules that perform various types of analysis. Design Globalization Interoperability Maintainability Mobility Naming Performance Portability Reliability Security Usage Below are the steps for Installation and configuration of FxCorp tool:

Create Language translator using ASP.NET

Below screenshot will be the example where you can see the text that we write on text box will convert into selected language. To translate text into multiple language we need to call webservices.There are multiple number of service code available in google so it will not be a problem.you can select anyone and can create for your site.

Programmatically create web part for mobile in SharePoint2010

In SharePoint 2010 all mobile devices are redirected by default to the mobile SharePoint rendering engine. The mobile rendering engine of SharePoint provides mobile users access to the sites with a completely stripped interface. Its main function is to list all libraries and to provide basic access to them. 1. Create a Visual Studio 2010 Visual Web Part Project

Create Personalize Application toolbar in SharePoint 2010

In this article I am going to explain about the application toolbar which will display the applications based on the current login users. To achieve the requirement we need to create two custom lists i.e. "All Apps" and "User App" " All Apps" list will have the below columns: " User Apps " list will have the below columns:

Custom Sandbox Application Page in SharePoint2010

From my previous article for " Reference web part in SharePoint 2010 ", I am extending the same sandbox solution with this article. So you just need to download code for sandbox web part and follow the steps below. The Sandbox in SharePoint 2010 allows Site Collection administrators to upload solutions in their Site Collections without access to the physical server. Sandbox Solutions do have some limitations, for instance we cannot add new application pages. Application pages are normally pages added to the _layouts folder, which are located in the 14 hive\TEMPLATE\LAYOUTS physical folder on each server. Sandboxed solutions still allows us to upload Content Pages; that is pages that are located in a document library for instance. The following are the steps to create a custom page in sandbox solution. 1. Create a project

Reference webpart in SharePoint 2010

In this article I am just going to explain how to create a reference webpart programmatically. Requirement: Need a webpart that display all pages title with link. Only related page should display in the link. Webpart should be added in all pages. Same page should not have hyperlink. In other words the query will return the page where the webpart is present. But it should have Hyperlink only with other pages. Namespaces : using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; using System.Text.RegularExpressions; using System.Text; Logic: using (SPSite site = SPContext.Current.Site)             {                              using (SPWeb web = site.OpenWeb())                 {                     SPList list = web.Lists["Pages"];                     SPQuery fieldQuery = new SPQuery();                     fieldQuery.Query = @"<Where>                                       <Eq>                                          <FieldRef Name='P_Article

Form Based Authentication in MOSS2010 Against SQL Server Database

Configuration: Step by step screenshot for FBA implementation In SQL: Create one web application for membership: Create Web Application(example moss:1111 and extend this application to http:// moss:1112 for From-based authentication) Changes in Web.config

How to use Mobile Entree Excel Addin in SharePoint 2010

Description : In this article I will just explain how to use Mobile Entree Excel Addin (SharePoint BI)  in SharePoint 2010 with sample example. Install Excel Add : To install the Excel AddIn go to the site, click on Mobile Entree Configuration->Global Config Excel Addin : After installation of Mobile Entree AddIn, we will get an option in Excel under "Insert" section named "Mobile View Configuration". This AddIn will help you to set a view when we open Excel in a mobile browser. Following are the steps for creating Mobile view in Excel: Step 1 . Create New DashBoard. Give it a name such as "My Dashboard".

Programmatically create custom role in selected sub sites in SharePoint 2010

In this article I am explaining how to create a custom role in SharePoint using C#. A custom role is required in SharePoint when you need to assign a role to the user as per the requirement not the OOTB. Add this code to your solution to add the custom role based on the sub site. I have the following scenrio: Person: People picker that will be used to add a user. Country: Listbox containing the list of subsites where we will add the user and assign roles. Administrator type: Type of custom role where we will assign to the selected user in selected susbsite (Country). Code : private void AddUserToGroup(string selectedUser, string userGroupName,string subSite) { SPSecurity.RunWithElevatedPrivileges(delegate { using (SPSite spSite = new SPSite(SPContext.Current.Site.Url)) { using (SPWeb spWeb = spSite.AllWebs[subSite { try { spWeb.AllowUnsafeUpdates = true; SPUser spUser = spWeb.EnsureUser(selectedUser); spWeb.RoleDefinitions.BreakInheritance(true, true); SPRoleDefinition role; switch(use

Steps for enabling archival policies in Form library

1. Open the form library, Go to Settings-> Form Library Settings 2. Click on Workflow settings->Add workflow

Display SharePoint Users, Groups and Sites in a GridView and Use a DropDownList to filter the values

This article will explain how to display SharePoint Users, Groups and Sites in a Gridview and use a DropDownList to filter the values. Step 1 : Open the Visual Studio and create a new project; select visual webpart (I am giving an example using a visual webpart). Step 2: Add the GridView to your user control, e.g. <asp:GridView ID="gvLists" runat="server" AutoGenerateColumns="False" CellPadding="4" EnableModelValidation="True" ForeColor="#333333" GridLines="None" OnRowCommand="gvLists_RowCommand"> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> <Columns> <asp:TemplateField HeaderText="Select"> <ItemTemplate> <asp:CheckBox ID="chk_Selected" runat="server" Style="position: static" />

How to get current Pages details in SharePoint2010 publishing site

Hi friends, Through this blog I just want to share my experince that how to recognize your current page or can get page detail for your current from sharepoint page library. You need to use the below code: char[] delimiters = new char[] { '\\', '?' }; string s = Page.Request.Path.ToString(); string[] words = s.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); int i = words[0].IndexOf("Pages/");