Friday, March 2, 2012

Not to allow Contributor users to access webpart menu of the webparts

Put this JavaScript just before “</BODY>”  on Master Page .
<script language="JavaScript">
    var doc = document.getElementsByTagName('ie:menuitem');
    for (var i = 0; i < doc.length; i++) 
    {
        itm = doc[i];
        if (itm.id.match('MSOMenu') != null) 
        {
            itm.hidden = true; 
        }
    } 
</script>

For More Option:
http://blogs.msdn.com/b/tejasr/archive/2010/03/26/not-to-allow-contributor-users-to-access-webpart-menu-of-the-webparts.aspx

Thursday, March 1, 2012

Change Service Account for Web Application in Central Admin Using PowerShell


$WebApplication = Get-SPWebApplication <ApplicationURL>;

$ManagedAccount = Get-SPManagedAccount -Identity "<Domain Name>\<UserName>";

$WebApplication.ApplicationPool.ManagedAccount = $ManagedAccount;

$WebApplication.ApplicationPool.Update();

$WebApplication.update();


Thursday, February 23, 2012

Remove "Launch blog program to post" from the SharePoint 2010 blog page

Remove "Launch blog program to post" from the SharePoint 2010 blog page or Blog Tool Webpart by adding the below CSS code :

<style type="text/css">
.ms-blogAdminLinks li+li+li+li
{
    display: none;
}
</style>

You can add this CSS code to your Master Page or Use a content editor.

Saturday, February 18, 2012

Remove duplicate elements from a List

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
 // List with duplicate elements.
 List<int> list = new List<int>();
 list.Add(1);
 list.Add(2);
 list.Add(3);
 list.Add(3);
 list.Add(4);
 list.Add(4);
 list.Add(4);
Console.WriteLine("Original List");
foreach (int value in list) { Console.WriteLine("{0}", value); } // Get distinct elements and convert into a list again. List<int> distinct = list.Distinct().ToList();
       Console.WriteLine("Distinct List");
foreach (int value in distinct) { Console.WriteLine("{0}", value); } } }
OUTPUT

Original List                                Distinct List
1                                                        1
2                                                        2
3                                                        3
3                                                        4
4
4
4

Thursday, February 16, 2012

Create a Chart Dynamically in SharePoint 2010














        public void DrawGraph(DataTable dt, string chartTitle)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("<script type='text/javascript' src='https://www.google.com/jsapi'></script>");
            sb.AppendLine("<script type='text/javascript'>");
            sb.AppendLine("google.load('visualization', '1', {packages:['corechart']});");
            sb.AppendLine("google.setOnLoadCallback(drawChart);");
            sb.AppendLine("function drawChart() {");
            sb.AppendLine("var data = new google.visualization.DataTable();");
            sb.AppendLine("data.addColumn('string', 'Title');");
            sb.AppendLine("data.addColumn('number', 'Rating');");
            sb.AppendLine("data.addRows([ ");
            foreach (DataRow drow in dt.Rows)
            {
                sb.AppendLine("['" + drow["Title"] + "'," + drow["Rating"] + "],");
            }
            sb.AppendLine("['',0]");
            sb.AppendLine("]);");
            sb.AppendLine("var options = {");
            sb.AppendLine("width: 800, height: 360,");
            sb.AppendLine("title: '" + chartTitle + "',");
            sb.AppendLine("hAxis: {title: 'Title', titleTextStyle: {color: 'white'}}};");
            sb.AppendLine("var chart = new google.visualization.ColumnChart(document.getElementById('chart_div" + chartTitle.Substring(0, 2) + "'));");
            sb.AppendLine("chart.draw(data, options);      }   ");
            sb.AppendLine("</script>");
            sb.AppendLine("<div id='chart_div" + chartTitle.Substring(0, 2) + "'></div>");
            pnlChart.Controls.Add(new LiteralControl(sb.ToString()));
        }



For More Chart Controls check the below link
Google Charts


How to launch a document by clicking a link to the file?

Word: <a href='ms-word:ofe|u|path/to/web/word/document.docx'>Link to document</a> Excel: <a href='ms-excel:o...