Saturday, December 29, 2012

Form field date validation using javascript

<script language=”javascript” type=”text/javascript”>
function PreSaveAction()
{
var date1 = getTagFromIdentifierAndTitle(“INPUT”,”DateTimeFieldDate”,”Start Date”);
var date2 = getTagFromIdentifierAndTitle(“INPUT”,”DateTimeFieldDate”,”End Date”);
var arrDate1 = date1.value.split(“/”);
var useDate1 = new Date(arrDate1[2], arrDate1[1]-1, arrDate1[0]);
var arrDate2 = date2.value.split(“/”);
var useDate2 = new Date(arrDate2[2], arrDate2[1]-1, arrDate2[0]);
if(useDate1 > useDate2)
{
alert(“The End Date cannot happen earlier than the Start Date”);
return false; // Cancel the item save process
}
return true; // OK to proceed with the save item
}
function getTagFromIdentifierAndTitle(tagName, identifier, title) {
var len = identifier.length;
var tags = document.getElementsByTagName(tagName);
for (var i=0; i < tags.length; i++) {
var tempString = tags[i].id;
if (tags[i].title == title && (identifier == "" || tempString.indexOf(identifier) == tempString.length – len)) {
return tags[i];
}
}
return null;
}
</script>

Hiding a field in newform.aspx

<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('h3:contains("FieldName")').closest('tr').hide();
});</script>

Friday, December 14, 2012

To Lock or Unlock a site collection by using Central Administration

TO LOCK A SITE COLLLECTION

1. Verify that you have the following administrative credentials. 
      • You must be a member of the Site Collection Administrators group for the site collection.

2. In Central Administration, click Application Management.

3. On the Application Management page, in the Site Collections section, click Configure quotas and locks. The Site Collection Quotas and Locks page opens.

4. If you want to change the selected site collection, in the Site Collection section, on the Site Collection menu, click Change Site Collection. Use the Select Site Collection page to select a site collection.

5. On the Site Collection Quotas and Locks page, in the Site Lock Information section, select one of the following options:
     •Not locked: To unlock the site collection and make it available to users.
     •Adding content prevented: To prevent users from adding new content to the 
       sitecollection. Updates and deletions are still allowed.
     •Read-only (blocks additions, updates, and deletions)
       To prevent users from adding, updating, or deleting content.
     •No access: To prevent access to content completely. 
       Users who attempt to access the site receive an access-denied message.

6. If you select Adding content prevented, Read-only (blocks additions, updates, and deletions), or No access, type a reason for the lock in the Additional lock information box.

7. Click OK.

TO UNLOCK A SITE COLLLECTION


1.Verify that you meet the following minimum requirements: See Add-SPShellAdmin.

2.On the Start menu, click All Programs.

3.Click Microsoft SharePoint 2010 Products.

4.Click SharePoint 2010 Management Shell.

5.At the Windows PowerShell 2.0 command prompt, type the following command:
      Set-SPSite -Identity "<SiteCollection>" -LockState "<State>"

Where:
•<SiteCollection> is the URL of the site collection that you want to lock or unlock.
•<State> is one of the following values:
Unlock: To unlock the site collection and make it available to users.
NoAdditions: To prevent users from adding new content to the site collection. Updates and deletions are still allowed.
ReadOnly: To prevent users from adding, updating, or deleting content.
NoAccess: To prevent access to content completely. Users who attempt to access the site receive an access-denied message.


Thursday, December 13, 2012

Manage blocked file types (SharePoint Server 2010)

Add or remove blocked file types
Use this procedure when you want to prohibit files of a specific type from being saved or retrieved from any Web application on a server.
To add or remove blocked file types by using Central Administration
  1. Verify that you have the following administrative credentials.(You must be a farm administrator on the server.)
  2. In Central Administration, click Security.
  3. On the Security page, in the General Security section, click Define blocked file types.
  4. On the Blocked File Types page, if you want to change the selected Web application, on the            Web Application menu, click Change Web Application. Use the Select Web Application page to select a Web application.
  5.  Do one of the following:
  • To block an additional file type, scroll to the bottom of the Type each file extension on a separate line text box, type the file extension you want to block, and then click OK.
Note:
You do not have to type a file extension in the list in alphabetical order. The next time you open the list, the file extension you added will be correctly sorted in alphabetical order.

· To stop blocking a file type, select a file type from the list, press the Delete key, and then click OK.

Monday, December 10, 2012

Install Timer Job by Management Shell


Add-SPSolution "filepath"
Install-SPSolution -Identity “wspname” -GACDeployment
Enable-SPFeature “feature name” -url “Siteurl
If you get an error then
Disable-SPFeature “feature name”  -url “Siteurl
Then again enable
Enable-SPFeature “feature name”  -url “Siteurl

Friday, November 30, 2012

SharePoint Management PowerShell scripts

SharePoint Management PowerShell scripts

Delete SharePoint alerts for orphaned (deleted) users


  1 
  2 $12HiveDir = "${env:CommonProgramFiles}\Microsoft Shared\web server extensions\12\"
  3 cd $12HiveDir
  4 [void][reflection.assembly]::Loadwithpartialname("Microsoft.SharePoint") | out-null
  5 [void][reflection.assembly]::Loadwithpartialname("Microsoft.Office.Server.Search") | out-null
  6 [void][reflection.assembly]::Loadwithpartialname("Microsoft.Office.Server") | out-null
  7 
  8 $farm = [Microsoft.SharePoint.Administration.SPFarm]::Local 
  9 $websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]} 
 10 $webapps = @()
 11 
 12 #Change this to match your domain, or even include the OU
 13 $LDAP_Domain = "LDAP://DC=contoso,DC=local"
 14 
 15 #From Check-SharePoint-Orphaned-Users: http://sharepointpsscripts.codeplex.com/releases/view/21699
 16 function Check_User_In_ActiveDirectory([string]$LoginName, [string]$domaincnx)
 17 {
 18     $returnValue = $false
 19     #Filter on User and NTgroups which only exists
 20     $strFilter = "(&(|(objectCategory=user)(objectCategory=group))(samAccountName=$LoginName))"
 21     $objDomain = New-Object System.DirectoryServices.DirectoryEntry($domaincnx)
 22 
 23     $objSearcher = New-Object System.DirectoryServices.DirectorySearcher
 24     $objSearcher.SearchRoot = $objDomain
 25     $objSearcher.PageSize = 1000
 26     $objSearcher.Filter = $strFilter
 27     $objSearcher.SearchScope = "Subtree"
 28 
 29     #$objSearcher.PropertiesToLoad.Add("name")
 30 

SharePoint Default Form date field validation using JavaScript


<script language=”javascript” type=”text/javascript”>
function PreSaveAction()
{
var date1 = getTagFromIdentifierAndTitle(“INPUT”,”DateTimeFieldDate”,”Start Date”);
var date2 = getTagFromIdentifierAndTitle(“INPUT”,”DateTimeFieldDate”,”End Date”);
var arrDate1 = date1.value.split(“/”);
var useDate1 = new Date(arrDate1[2], arrDate1[1]-1, arrDate1[0]);
var arrDate2 = date2.value.split(“/”);
var useDate2 = new Date(arrDate2[2], arrDate2[1]-1, arrDate2[0]);
if(useDate1 > useDate2)
{
alert(“The End Date cannot happen earlier than the Start Date”);
return false; // Cancel the item save process
}
return true; // OK to proceed with the save item
}
function getTagFromIdentifierAndTitle(tagName, identifier, title) {
var len = identifier.length;
var tags = document.getElementsByTagName(tagName);
for (var i=0; i < tags.length; i++) {
var tempString = tags[i].id;
if (tags[i].title == title && (identifier == “” || tempString.indexOf(identifier) == tempString.length – len)) {
return tags[i];
}
}
return null;
}
</script>

Monday, October 15, 2012

QUICK TIP – JQUERY COLLAPSABLE QUICKLAUNCH FOR SHAREPOINT 2010


Enable an end user to hide the Quicklaunch from view and free up some additional space if you have a lower resolution. download jquery-1.6.2.min.js and copy this snippets on Master page.

<script type="text/javascript" src="/Shared%20Documents/jquery-1.6.2.min.js"></script>

<script type="text/javascript">
jQuery(function($) {
        var CookieName = "QuickLaunchHidden";
   var MainArea = $('.s4-ca');
   var MainAreaLeftMargin = $(MainArea).css('margin-left');
   var NoLeftMargin = "0px";
   var LeftArea = $('#s4-leftpanel');
   var Collapse = "/_layouts/images/mewa_leftPage.gif";
   var Expand = "/_layouts/images/mewa_rightPage.gif";

   $(MainArea).prepend('<a class=\'min\' style=\'float:left; position:absolute; top:0px; left:0px;\' title=\'Hide \\ Show Quick Launch\'><img src=\''+

Collapse +'\'/></a>');

   $('.min').click(function(){
//Toggle the Left Panel to hide it
$(LeftArea).toggle();
$(LeftArea).is(":visible") ? MainArea.css('margin-left',MainAreaLeftMargin ) :  MainArea.css('margin-left',NoLeftMargin);
var img = $(this).children();
$(LeftArea).is(":visible") ? img.attr('src',Collapse) : img.attr('src',Expand );
});
});
</script>
For more information:
http://www.lifeinsharepoint.co.uk/2012/06/19/quick-tip-jquery-collapsable-quicklaunch-sharepoint-2010/

Sunday, September 30, 2012

SharePoint’s Branding Limitations

SharePoint 2010 CSS Page Elements



.s4-toplinks {
background-color: #899DC2;
}
body #s4-ribboncont {
background-color:#4D6193;
}
.v4master .ms-siteactionsmenuinner {
background-color:#949391;
}
.ms-cui-cg-db .ms-cui-cg-t{
color:#343332;
}
.ms-cui-tt-a:Hover {
color:#899DC2 !important;
background-color:#FFFFFF;
}
.s4-ql UL.root > LI > .menu-item {
color:#899DC2;
}
.s4-tn LI.static > .menu-item {
color:#FFFFFF;
}
.s4-toplinks .s4-tn A.selected {
border-color:#A7BADA;
color:#003759;
background-color: #A7BADA;
}
.s4-toplinks .s4-tn A:Hover {
border-color:#899DC2;
color:#000000 !important;
}
.s4-ql A.selected {
background-color: #A7BADA;
}
.ms-WPHeader A, .ms-addnew A {
color:#899DC2 !important;
}



Data View Web Part

SharePoint Backup Method for Every Day of the Week


# Standard Load of the SharePoint plugin for PowerShell, nothing special here
$snapin = (Get-PSSnapin -name Microsoft.SharePoint.PowerShell -EA SilentlyContinue)

IF ($snapin -ne $null){write-host "SharePoint Snap-in is loaded"}
ELSE { write-host "SharePoint Snap-in not found... Loading now"
Add-PSSnapin Microsoft.SharePoint.PowerShell
write-host "SharePoint Snap-in is loaded"
}
# END Loading SharePoint Snapin

# Lets get the day of the week using the DateTime object
([system.datetime]$date = $([system.datetime]::now))
$dayofweek = $date.DayOfWeek

#set the location where you want to backup the farm
$backupDirectory = "\\server\folder\subfolder"

#If its Sunday let's do a full backup instead of a differental
if($dayofweek -eq "Sunday")
{
write-host "$dayofweek - Full Backup being Executed"
Backup-SPFarm -Directory $backupDirectory -BackupMethod Full
}
else
{
#Its not Sunday, so let's just do a differential backup
Write-Host "$dayofweek - Differential Backup Being Executed"
Backup-SPFarm -Directory $backupDirectory -BackupMethod Differential
}

SharePoint 2013 Top 10 New Features


  1. Support the tools designers use: Flexibility in Branding – How great will it be that your designers can use Dreamweaver or other popular design products. More information on TechNet Branding Features
    "Whether that is Adobe Dreamweaver, Microsoft Expression Web, or some other HTML editor. To brand a SharePoint site, designers just create a site design as they typically would, by implementing HTML, CSS, and JavaScript"
  2. Offline and Sync of My Site (and other libraries) – "In SharePoint Server 2013 Preview, My Sites include several improvements to saving, synchronization, sharing, and moving of content. Users have the option to synchronize their My Site document library content with a local drive to enable offline access to documents." Saving and Syncing Content (I really love the new Follow people, documents, sites, and tags to customize their feed!!)
  3. Search Engine Optimization & Analytics is in Search – Search is TONS better. Much of this is due to Analytics moving into search. This will make Analytics Processing Component in SharePoint Server 2013 Preview runs different analytics jobs to analyze content in the search index and user actions that were performed on a site to identify items that users perceive as more relevant than others. TechNet Analytics Recommendations
  4. Content Search WebPart – This webpart is cool, but it may take a demo to understand the power. In many ways this is the next generation of Content Query Web Part. "Content Search Web Part that displays content that was crawled and added to the search index. You can use category pages when you want to aggregate content that meets certain criteria or parameters. For example, in an intranet scenario, all company events are maintained in a list that is shared as a catalog. A query is issued from the Content Search Web Part to return all items from the search index that are specified in the query." Content Search Web Part
  5. Optimized mobile browser experience – For some companies this may be the reason to upgrade alone. Mobile is definitely something I have been looking for. "For smartphone mobile devices SharePoint Server 2013 Preview provides a lightweight, contemporary view browsing experience for users to navigate and access document libraries, lists, wikis, and Web Parts. Contemporary view.  This view offers an optimized mobile browser experience to users and renders in HTML5. This view is available to Mobile Internet Explorer version 9.0 or later versions for Windows Phone 7.5, Safari version 4.0 or later versions for iPhone 4.0, and the Android browser for Android 4.0. Classic view   This view renders in HTML format, or similar markup languages (CHTML, WML, and so on), and provides backward compatibility for mobile browsers that cannot render in the new contemporary view" Mobile browser experience Device specific Master Pages – You can target your branding to the device! Targeting different devices such as smartphones, tablets. "Allow a single publishing site to be rendered in multiple ways by using different designs that target different devices." TechNet Device Specific Branding Feature
  6. Rich Workflows – If workflows were a sore point, they've gotten a lot better and seem much more able to handle more complex activities including looping and working with webservices (anyone thinking orchestration?). "A new action that enables no-code web service calls from within a workflow, New actions for creating a task and starting a task process and New workflow building blocks such as Stage, Loop, and App Step" With Azure Workflows you can even do "REST and Service Bus Messaging" Workflow in SharePoint 2013 Machine Translation – Looking forward to really seeing what our business can do with this translation service. Automated translation into various languages!
  7. Development gets more familiar – Developers who are not SharePoint developers will find SharePoint 2013 preview a lot easier to work with. Leverage your existing "ASP.NET, Apache, C#, Java, and PHP. The new cloud app model gives you the freedom of choice." Familiar development environments
  8. New App Model – This new app model will take you into the New Online World – "The new app model embraces web standards: You can develop the user experience with HTML and JavaScript, and leverage SharePoint and other REST services right from the client using JavaScript and JSON. You can even create your own REST services and provide a web hosting platform of your choice to handle complex logic and integration of data and services. The new cloud app model also takes advantage of OAuth to allow for secure communication between SharePoint and remote hosted apps and services." Familiar tools – App Model
  9. Shredded Storage – This is one of my favorite new features. I can't wait to see what it does to our farm. Shredded storage will remove file duplicates and reduce the amount of content sent across the wire. You can find more on this in the IT pro decks.
  10. Social Features: Activity feeds – I really like the idea that I can get real notifications of what's happening on a site including following documents, following sites, and following people… and automatically following team members (if you want).Communities – I think Microsoft's new site template communities will be interesting with integrated microblogging.

Friday, August 31, 2012

Hide first link from global navigation

.s4-tn li.static > a{
display: none !important;
}
.s4-tn li.static > ul a{
display: block !important;
}

Wednesday, August 8, 2012

Hide column on SharePoint list forms - JavaScript

Hide column on Sharepoint Dispform.aspx, Editform.aspx, Newform.aspx using a JavaScript.
Copy the script on desired form under the
<asp:Content ContentPlaceHolderId="PlaceHolderAdditionalPageHead" runat="server"> tag:

<script language="javascript" type="text/javascript">
_spBodyOnLoadFunctionNames.push("hideFields");
function findacontrol(FieldName) {
   var arr = document.getElementsByTagName("!");
   // get all comments
   for (var i=0;i < arr.length; i++ )
   {
      // now match the field name
      if (arr[i].innerHTML.indexOf(FieldName) > 0)
      {         return arr[i];      }
   }
}

function hideFields() {
var control = findacontrol("Column-1");
control.parentNode.parentNode.style.display="none";

control = findacontrol(" Column-2");
control.parentNode.parentNode.style.display="none";
}
</script>

Tuesday, August 7, 2012

Error 401.1 when browsed a web that uses Integrated Authentication and is hosted on IIS


1.       Click Start, click Run, type regedit, and then click OK.
2.       In Registry Editor, locate and then click the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0
3.       Right-click MSV1_0, point to New, and then click Multi-String Value.
4.       Type BackConnectionHostNames, and then press ENTER.
5.       Right-click BackConnectionHostNames, and then click Modify.
6.       In the Value data box, type the host name or the host names for the sites that are on the local computer, and then click OK.
7.       Quit Registry Editor, and then restart the IISAdmin service.

Friday, July 20, 2012

Remove User from User Information Table

Remove a single user from User Information table:
Remove a user based on Login Name
web.AllowUnsafeUpdates = true;
string userName = "domainname\\username";
SPUser user = web.SiteUsers[userName];
 if (!user.IsDomainGroup && !user.IsSiteAdmin)
     {
         web.SiteUsers.Remove(user.LoginName);
          web.Update();
     }
web.AllowUnsafeUpdates = false;


Remove Multiple user:
Remove multiple user based on Domain name
web.AllowUnsafeUpdates = true;
SPList _list = web.Lists.TryGetList("User Information List");
SPQuery qry = new SPQuery();
qry.Query = "<Where><Contains><FieldRef Name='Name' /><Value Type='Text'>Domainname</Value></Contains></Where>";
SPListItemCollection _itmcol = _list.GetItems(qry);
if (_itmcol.Count > 0)
  {
      string userName = "";
     foreach (SPListItem itm in _itmcol)
      {
        userName = Convert.ToString(itm["Name"]);
        SPUser user = web.SiteUsers[userName];
        Console.WriteLine(userName + "("+ Convert.ToString(itm["Title"])+ ")" + "\n");
        web.SiteUsers.Remove(user.LoginName);
        web.Update();
      }
 }
web.AllowUnsafeUpdates = false;

Can't access/open Central Administration


Error: 
System.ArgumentNullException: No message was deserialized prior to calling the DispatchChannelSink.
Parameter name: requestMsg  
at System.Runtime.Remoting.Channels.DispatchChannelSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders & responseHeaders, Stream& responseStream)
at System.Runtime.Remoting.Channels.SoapServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)  
at System.Runtime.Remoting.Channels.Http.HttpServerTransportSink.ServiceRequest(Object state)  
at System.Runtime.Remoting.Channels.SocketHandler.ProcessRequestNow().

Reason: 
May be your SharePoint Central Administration port is used by another process.
Solution:
  1. Open Command Prompt(with Run as Administrator).
  2. Run this command netstat -na -nao.
  3. Now you can see your Active connections.
  4. Find you Central admin port ID.
  5. Here Central Admin Port ID is 8093 PID is 4088.
  6. Go to Task Manager > Services> find your PID (like 4088).
  7. Right click on that select Go to Process.
  8. Kill/Close the selected Process. (Note: if no one process is selected check the show process from all user check box below).
  9. Reset IIS.
  10. Now try to access you Central Administration :)

Friday, June 8, 2012

Sharepoint Server - Upgrade Standalone to Farmserver


Take a backup of your Database, sites and your all web application’s Virtual directory .
1.      Go to Registry Editor:
·         Go to Registry Editor
·         Select HKEY LOCAL MACHINE
·         Select Software
·         Select Microsoft
·         Select Shared Tools
·         Select Web Server Extension
·         Select 14.0
·         Select WSS
·         On WSS select Server Role Right Click and modify Value Data as “APPLICATION”
                      
                          

2.      Go to Central Administration Run Configuration Wizard
·         Choose disconnect from the Server Farm
·         Configuration Success

3.      Install Two HotFix

Note: Before you install this hotfix If you decide to install this hotfix, please note the following items: Do not deploy a hotfix in a production environment without first testing the hotfix. Back up the system or the computer that will receive the hotfix before you install the hotfix.

·         Once the download is complete run the self-extracting file & then run the extracted file so as to install the Sharepoint 2010 Patch.
·         Restart the server once the installation is complete.
·         Furthermore, run the Configuration Wizard as earlier & follow the on-screen instructions.
·         Select the option to create a “New Farm”.
·         Then, provide the New Full SQL Server Instance details : “Computername\SqlServerInstance”
·         Database : SharePoint_Config
·         Account : “DomainName\Username”
·         Afterwards select the option to provision Central Administration Site stating that this machine will host the said site.
·         Once the wizard completes all the steps successfully it will open the Central Administration Site.
·         Cancel the configuration wizard in the browser which appears.
·         Furthermore, Create a New Web Application on Port 80 with a temporary database.
·         Then detach the database by opening Manage content databases under Application Management for SharePoint – 80 Web Application.
·         Restore the backedup database “WSS_Content” to the New Full SQL Server Instance
·         After which, open SharePoint 2010 Management Shell as an Administrator.
·         stsadm -o addcontentdb -url “Url”-databasename WSS_Content

Tuesday, May 29, 2012

Web Part life cycle in SharePoint 2010


OnInit: This method handles initialization of the control.

OnLoad: This event handles the Load event. This is also used for initialize the control but is not intended for loading data or other processing functionality.

CreateChildControls: This is the most popular event in web part life cycle. This creates any child controls. So if you are adding any control to display then you have to write in this method.

EnsureChildControls: This method ensures that CreateChildControls has executed.
EnsureChildControls method must be called to prevent null reference exceptions.

SaveViewState: View state of the web part saved.

OnPreRender: This method handles or initiates tasks such as data loading that must complete before the control can render. 

Page.PreRenderComplete: The page fires the PreRenderComplete event after all controls have completed their OnPreRender methods.

Render: This method is used to render everything.

RenderContents: Renders the contents of the control only, inside of the outer tags and style properties.

OnUnload: Performs the final cleanup.

Missing PDF icon images in SharePoint 2010

Missing PDF icon images in SharePoint 2010

Converting Word Documents to PDF using SharePoint Server 2010 and Word Services

Wednesday, April 11, 2012

Convert a Docx file to HTML


//Add Reference
using System.Reflection; // Microsoft.Office.Interop.Word.dll

//Source File
 string strSource=@"D:\Documentfile.docx";
// Destination  File
 string strDestination=@"D:\htmlfile.html";

// Constant for WORD-TO-HTML exporting format
const int WORD_HTML_FORMAT = 8;

// Load COM-Metadata of Word application from registry
Type tWordApplication = Type.GetTypeFromProgID("Word.Application");

// Create new instance of Word
object objWord = Activator.CreateInstance(tWordApplication);

// List all documents
object objDocuments = tWordApplication.InvokeMember("Documents", BindingFlags.IgnoreCase | BindingFlags.GetProperty | BindingFlags.Public, null, objWord, new object[0]);

// Get COM-Metadata of Word Documents
Type tWordDocuments = objDocuments.GetType();

// Load source
object objDocument = tWordDocuments.InvokeMember("Open", BindingFlags.IgnoreCase | BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.OptionalParamBinding, null, objDocuments, new object[1] { strSource });

// Get COM-Metadata of Word Documents
Type tWordDocument = objDocument.GetType();

// Create HTML
tWordDocument.InvokeMember("SaveAs", BindingFlags.IgnoreCase | BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.OptionalParamBinding, null, objDocument, new object[2] { strDestination, WORD_HTML_FORMAT });

// Close Word
tWordApplication.InvokeMember("Quit", BindingFlags.IgnoreCase | BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.OptionalParamBinding, null, objWord, new object[0]);

Publishing image field Url Sharepoint 2010

using ImageFieldValue = Microsoft.SharePoint.Publishing.Fields.ImageFieldValue;


ImageFieldValue value = item["FieldName"] as ImageFieldValue;
                                    string imageUrl = "";
                                    if (value != null)
                                    {
                                        imageUrl = value.ImageUrl;
                                    }
                                    else
                                    {
                                        imageUrl = "";
                                    }


Tuesday, April 3, 2012

Unable to open Document Library in Explorer View

If you're unable to open document library in Explorer view follow these steps:
(your client does not support opening this list with windows explorer)
1. Add your site as a trusted site list in your Browser tools option

  • Start Internet Explorer.
  • On the Tools menu, click Internet Options, and then click the Security tab.
  • Click Trusted sites, and then click Sites.
  • In the Trusted sites dialog box, type the URL (http://servername:port) of your site in the Add this website to the zone box, and then click Add.
  • Click Close, and then click OK.
2.  Make sure the Web client service is Started.
3. If your are using server Machine means install Desktop Experience Feature
 

Microsoft Support

You can directly check your issues of Microsoft Products with Microsoft support service site

http://support.microsoft.com/search/




Remove obsolete users and groups


Maintain profile synchronization (SharePoint Server 2010)


Remove absolute user from User Profile  [ MSDN link]

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


Tuesday, February 7, 2012

SharePoint Site Error: Service Unavailable HTTP Error 503. The service is unavailable

When opening My SharePoint site it giving me the error ‘Service Unavailable HTTP Error 503. The service is unavailable’ and I was not able to access either of them.

It was stopped at the IIS when i'm start manually i got the same error. I realized that I had just changed the password of my account. So here is share what I did to solve the problem.

1. Open up IIS Manager and click on 'Application Pools'.

2. Locate your App Pool account and right-click on it and select 'Advanced Settings'.

3. Under the Process model Group click on 'Identity' then Application Pool Identity Pop up is opened Click on 'Set' and re-enter My User Name, Password and Confirm Password then click on 'OK'.

Error is cleared...

Hope it will help you...

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...