Friday, December 27, 2013

Invalid characters in SharePoint naming conventions

This article lists the characters that you cannot use in the following names in Microsoft SharePoint:

  • Site names
  • Folder name
  • Server names
  • File names

Site names, subsite names, or site group names

  • You cannot use the following characters anywhere in a site name, in a subsite name, or in a site or Active Directory group name:-
    • Tilde (~)
    • Number sign (#)
    • Percent (%)
    • Ampersand (&)
    • Asterisk (*)
    • Braces ({ })
    • Backslash (\)
    • Colon (:)
    • Angle brackets ([ ])
    • Question mark (?)
    • Slash (/)
    • Plus sign (+)
    • Pipe (|)
    • Quotation mark (“)
  • You cannot start a site name, a subsite name, or a site group name with an underscore (_) character or with the period (.) character.
  • When you create a site name, a subsite name, or a site group name, you cannot use strings that were already used to name managed paths.
  • You cannot use the period character consecutively in the middle of a site name, a subsite name, or a site group name.
  • You cannot use the period character at the end of a site name, a subsite name, or a site group name.

Folder names

  • You cannot use the following characters anywhere in a folder name or a server name:
    • Tilde
    • Number sign
    • Percent
    • Ampersand
    • Asterisk
    • Braces
    • Backslash
    • Colon
    • Angle brackets
    • Question mark
    • Slash
    • Pipe
    • Quotation mark
  • You cannot use the period character consecutively in the middle of a folder name.
  • You cannot use the period character at the end of a folder name.
  • You cannot start a folder name with a period character.

File names

  • You cannot use the following characters anywhere in a file name:
    • Tilde
    • Number sign
    • Percent
    • Ampersand
    • Asterisk
    • Braces
    • Backslash
    • Colon
    • Angle brackets
    • Question mark
    • Slash
    • Pipe
    • Quotation mark
  • You cannot use the period character consecutively in the middle of a file name.
  • You cannot use the period character at the end of a file name.
  • You cannot start a file name by using the period character.
  • In addition, file names and folder names may not end with any of the following strings:
    • .files
    • _files
    • -Dateien
    • _fichiers
    • _bestanden
    • _file
    • _archivos
    • -filer
    • _tiedostot
    • _pliki
    • _soubory
    • _elemei
    • _ficheiros
    • _arquivos
    • _dosyalar
    • _datoteke
    • _fitxers
    • _failid
    • _fails
    • _bylos
    • _fajlovi
    • _fitxategiak

Configure SSL for SharePoint 2013

Access SharePoint site using custom URL

Friday, December 20, 2013

Generate script for ALTER DB column Data for all tables available in DB

Run Below query to generate script:

SELECT
'ALTER TABLE ' + TABLE_NAME + ' ALTER COLUMN Createdby varchar(50) ;' +
'ALTER TABLE ' + TABLE_NAME + ' ALTER COLUMN Updatedby varchar(50) ;' AS Script
FROM INFORMATION_SCHEMA.TABLES

Take care of following items:

  • Above query generate scripts for all the tables which were created in that database, deleted tables are also included in it.
  • If tables contains that field or not it will generate script for that table also. Manually you have to remove that table script to run the generated scripts.
  • CreatedBy and UpdatedBy is the field name of the tables which I want to update.
  • Above query generates script for 2 fields, if you want to increase or decrease you have to update above query as per your requirement. 

Thursday, December 5, 2013

How to change Default Home Page : SharePoint

I frequently get questions on changing the home page or using another page as the home page:

  • Can I have three (or four or five or…) columns in the default home page?

  • Do I have to use the new wiki home page in my Team Site?

  • I want to test a new home page design, but I don’t want to lose the existing home page… (just in case you know…)

  • How can I use a page from my wiki library as my home page?


Below are four ways to set another page as your home page: (all four work for both 2007 and 2010)

  • From Site Settings (If the publishing features are enabled)

  • From SharePoint Designer

  • From code / API

  • From PowerShell


The first two can be used by Site Owners, the second two can only be used for developers and administrators

Important Notes for all methods:
Make sure all of your users have at least read access to the new home page, and if in a library that you have it checked in and published.

1.   If the Publishing features are enabled for a site then: (From Site Settings)


Click on Site Action  =>  Site Setting  =>  Welcome Page

Image

2.   From SharePoint Designer:


Right-click the new page and click "Set as Home Page".  (For SharePoint 2007 this only appears to work from SharePoint                    Designer if the file is in the root of the site. I.e. the same place as default.aspx.)

Image

3. From Code / API


Please follow the following link for code.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfolder.welcomepage.aspx

4. Via PowerShell


$site = Get-SPSite http://yourserver/sites/yoursite
$web = $site.RootWeb (or $web = $site.OpenWeb("yoursubsite")
$folder = $web.RootFolder
$folder.WelcomePage = "SitePages/home.aspx"
(or $folder.WelcomePage = "default.aspx")
(or $folder.WelcomePage = "Shared%20Documents/mycustomwebpartpage.aspx")
$folder.update()
$web.Dispose()
$site.Dispose()

If you need any type of help please let me know on following email id : jaydoshi.com@gmail.com. Thank You.

Tuesday, October 8, 2013

How to Close Model Dialog on Button Click

 
<asp:Button Text="Close" runat="server" ID="btnClose"
          OnClientClick="javascript:window.frameElement.commitPopup();" />

Thursday, September 12, 2013

Configure RDLC Report with ReportViewer : SharePoint 2010

I have worked with SharePoint 2010 Foundation and found the RDL(C) report is not configured automatically.  To run a successfully report I applied the following changes in SharePoint web.config file. To make sure the configuration works for reporting just put a reportviewer control inside a webpart/page and try to access the page. First of all make sure you have intalled “Microsoft Report Viewer 2010 Redistributable Package”. You can it from here.

Here I am going to list down steps to configure report viewer setting for SharePoint.

1.   First find the following line in AppSettings and comment it out as shown below:
 <!--<add key="ReportViewerMessages" value="Microsoft.SharePoint.Portal.Analytics.UI.ReportViewerMessages, Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />-->

2.   By default session is disabled in SharePoint. Enable it by ensuring an entry like below inside <system.web>.
<sessionState mode="InProc" timeout="60" />

3. Enable session at page level by setting the enableSessionState to true of <page…..> tag inside system.web.
<pages enableSessionState="true" enableViewState="true" enableViewStateMac="true" validateRequest="false" ……………………=""

4. SharePoint disable the default session module inside the <system.webserver>\modules tag. To enable the module comment out the following line inside <system.webserver>\moudles as shown below:
<!--<remove name="Session" />-->

Now if you try to put a reportviewer control in webpart/page, you will find a message as below:

Image

If you got/find above error message while accessing the report page then you are on right track. Please continue with following steps:

5. Add the following tag inside system.web\httphandlers section
<add verb="*" path="Reserved.ReportViewerWebControl.axd" type = "Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

6. Add the following line in the system.webserver\handlers
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

7. Comment out the following line in the system.WebServer\httphandlers (If Exists)
<!--<add name="ReportViewerWebControl" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />—>

 

That's it..!! Error will be resolved now. Enjoy..:)

Friday, September 6, 2013

How to call Server Side Method from jQuery/javascript using Ajax & JSON Parsing

With this post I would show how to call server side method from client side. Here I use jQuery to utilize the Ajax Capabilities which will help us to get/post data to/from server Asynchronously. There are many methods available to perform an async callback to the server. Here I will show a simple example as in how to call a code behind Webmethod.
For simplicity I would be calling the code behind method on a Button Click. Here is the code:

<asp:Button ID="Button1" runat="server" Text="Click" />
<br /><br />
<div id="myDiv"></div>

JQuery/JavaScript Code to call Server Side Method:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>
<script type ="text/javascript">
$(document).ready(function () {
$('#<%=Button1.ClientID %>').click(function () {
$.ajax({
type: "POST",
url: "WebForm1.aspx/ServerSideMethod",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
cache: false,
success: function (msg) {
$('#myDiv').text(msg.d);
}
})
return false;
});
});
</script>

Server Side Method (C# Code): (you must have to define your web method as public static)

[WebMethod]
public static string ServerSideMethod()
{
return "Message from server.";
}

In the above code, the aspx markup contains a button on click of which we would call the server side method named ServerSideMethod(). The div would show the message returned from the server. When you run the code above and click the button, it would the div would show the message "Message from server".
If you want to send parameters to your server side method / code behind method, you would replace the below line in the above jQuery code as:

data: "{'param1': 1}"    (Static Value)
data: "{'param1':"+ variableValue +"}" (If you want to pass Variable value

With the above line I would be sending a parameter with value as 1 to the server side method.
The server side method would change as:

[WebMethod]
public static string ServerSideMethod(string param1)
{
return "Message from server with parameter:"+param1;
}

You can also call your web service method from here URL attribute.
If you want to call your Web Method on confirmation box of Jquery then you can go with below code:

function MyConfirmMethod() {
if (confirm('Are your sure?')) {
$.ajax({
type: "POST",
url: "WebForm1.aspx/ServerSideMethod",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
$('#myDiv').text(msg.d);
}
});
return false;
}
else {
return false;
}
}

Server Side C# Method:

protected void Page_Load(object sender, EventArgs e)
{
Button1.Attributes.Add("onclick", "return MyConfirmMethod();");
}
[WebMethod]
public static string ServerSideMethod()
{
return "Message from server!";
}

Above you can see I am calling JavaScript confirm on the button click. On pressing yes, jQuery calls code behind method ServerSideMethod and returns back the message. You could perform any server side logic/database operations here based on the user response. Note I use return false as it prevents post-back to the server.

Thanks..:)

Tuesday, August 27, 2013

Session state has been disabled for ASP.NET. The Report Viewer control requires that session state be enabled in local mode

Solution for following error:Image

I had to install SharePoint Foundation 2010 for a new project. They needed a native Web Part, and the name of this was Report Viewer control

But a received a strange correlation-ID error and I could not open anymore my site. so I opened ULSVIEWER and got a stranger error: Session state has been disabled for ASP.NET. The Report Viewer control requires that session state be enabled in local mode

So I made some researches on internet and found always the same PowerShell Command:

Enable-SPSessionStateService ( "The only way to install ASP.Net Session State is through PowerShell using *-SPSessionStateService. [Enable | Disable | Get | Set]-SPSessionStateService" )

Reference:

Reference-1  Reference-2   Reference-3

The problem is that when I followed the directions for enabling session state using powershell, I could not find the cmdlet. I spent a ridiculous amount of time trying to figure this out since I had the correct powershell snapin, but I could not find that cmdlet.

 

To resolve this issue you need to change at 2 places.

     1. Do Following changes in your sharepoint web.config file

  • You need to edit the web.config file of the SharePoint application. Open your web.config and add the httpModules.

  • In the <system.web> section, find the <httpModules> element and edit it like the following:

  • <httpModules> <add name = “Session” type=”System.Web.SessionState.SessionStateModule” /></httpModules>

  • You also need to find the element tag <pages> (also under the <system.web> element) and look for the attribute called enableSessionState and set it to true if it is currently false. Save and close the web.config file.

 

     2. Now another thing is you need to add modules in IIS7

  • You should then open the IIS 7 manager, and select your web application.

  • Open the modules applet under the IIS section.

  • Click “Add Managed Module” in the right hand panel.Enter a name for the module, I chose “SessionState”, you can pick what you like, but I suggest something related to session state and then in the lower box, select the entry for:

  • System.Web.SessionState.SessionStateModule, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

Made an IISreset, and test again. you can now add your WebPart Report Viewer control to your site.

Monday, July 8, 2013

How to send requrest after executing Response.End() statement

Once I have to create a custom search on list item for some of the item fields and then it can be exported to excel. I successfully developed a custom visual web part which display only those record which fulfilling the search criteria and is transferred to excel. But then i face one problem that first time when i search the record and export it to excel it works fine. But for the second time my request is not sent to server because of using Response.End() function to avail the user to download the exported record in excel file.


So following is the solution for the same. Add below JavaScript in  your web part design page.


<script type="text/javascript">
document.ready({
        _spOriginalFormAction = document.forms[0].action;_spSuppressFormOnSubmitWrapper = true;
});
</script>

and append following code in your page load event.


System.Web.UI.ScriptManager scriptManager = System.Web.UI.ScriptManager.GetCurrent(this.Page);
scriptManager.RegisterPostBackControl(this.btnToExport);

Please replace this.btnToExport with your button or your control on which you handle click event to export it to excel.


 

Monday, July 1, 2013

How to decrease Content DB Size

If your content DB size is more than its actual size then you have to remove items from your Recycle Bin.

Once you remove your item from Site Action -> Recycle Bin it will transffered to Admin Recycle bin. You have to remove it from there also.

http://yoursite/_layouts/AdminRecycleBin.aspx?View=2

Once you removed your data from here now see the size of your content db. Its reduced now.

Thanks.

Friday, June 28, 2013

How to Display SharePoint Control in Display Mode in List Edit Page

I am facing the problem in which I need to display the SharePoint List Field in "Display" mode in List Edit Page. (This Problem works with SharePoint Default generated Page)

Step-1 : First of all please download the JavaScript file from here.

Step-2 : Add this JavaScript file in your project StyleLibrary.

Step-3 : Now Open your List Default Edit Page.

Step-4 : Find PlaceHolderMain tag. and after this tag insert you desired code as below:
<script type=text/javascript>
function MyCustomExecuteFunction()
{
//to hide the field Title=Field Display Name
     SPUtility.GetSPField('Title').Hide();
//enable to control in display mode
SPUtility.GetSPField()
   
}
_spBodyOnLoadFunctionNames.push("MyCustomExecuteFunction");
</script>

Other examples images are inserted below:

Image

Image

Image

Image

If you have any doubt in this article feel free to mail me or comment here.

Wednesday, June 19, 2013

Custom Code for send Mail in SharePoint using C# .net code

Create new project in Visural Studio create new Project by following the below step:

File -> New -> Project -> Visual C# -> Windows in Installed Template -> Select Console Application. Give your desire name to the application.

Add Following Reference in your code:
Microsoft.SharePoint

Add Following Name Space in you code:
using Microsoft.SharePoint;
using System.Net.Mail;

Replace Program.cs code with below code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using Microsoft.SharePoint.Administration;
namespace SendEmail
{
    class Program
    {
        static void Main(string[] args)
        {
            SPWebApplication webApp = SPWebApplication.Lookup(new Uri("https://serverName/"));
            MailMessage mail = new MailMessage();
            mail.From = new MailAddress("abc@xyz.com");
            mail.To.Add("pqr@xyz.com");
            mail.Subject = "Subject Test";
            mail.Body = "Body Test";
            // SmtpClient class sends the email by using the specified SMTP server
            SmtpClient smtp = new SmtpClient(webApp.OutboundMailServiceInstance.Server.Address);
            smtp.UseDefaultCredentials = true;
            smtp.Send(mail);
        }
    }
}

This will send mail from abc@xyz.com to pqr@xyz.com user. Subject of the mail is "Subject Test" and Body of the mail is "Body Test"

How to check current user in particular group in JavaScript using SPServices

Add two JavaScript file in your Style Library.

1. Javascript 1.7.1.js (Download from here)

2. jquery.SPServices-0.7.1a.min.js (Download from here)
<script type="text/javascript" src="/Style%20Library/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="/Style%20Library/js/jquery.SPServices-0.7.1a.min.js"></script>
<script language="javascript" type="text/javascript">

$(document).ready(function () {        
        $().SPServices({
            operation: "GetGroupCollectionFromUser",
            userLoginName: $().SPServices.SPGetCurrentUser(),
            async: false,
            completefunc: function (xData, Status) {
                if ($(xData.responseXML).find("Group[Name='SPGroup1']").length == 1) {
                    location.href = location.href.replace('/EditFormMKT.aspx', '/EditFormUW.aspx');
                }
                else if ($(xData.responseXML).find("Group[Name='SPGroup2']").length == 1) {
                    location.href = location.href.replace('/EditFormMKT.aspx', '/EditFormLegal.aspx');
                }
                else if ($(xData.responseXML).find("Group[Name='SPGroup3']").length == 1) {
                    location.href = location.href.replace('/EditFormMKT.aspx', '/EditFormDesigner.aspx');
                }
                else if ($(xData.responseXML).find("Group[Name='SPGroup4']").length == 1) {
                    location.href = location.href.replace('/EditFormMKT.aspx', '/EditFormRequester.aspx');
                }
            }
        });
    });
</script>

Group1, Group2 and Group3 etc are SharePoint Groups. Replace your group name with this group name and what ever you want to do write your code below of it.

Here I am replacing the URL and redirect the user based on his role. You can also call particular JavaScript function based on user's group.

Hope this is helpful to you.

Tuesday, June 18, 2013

Using PowerShell to deploy SharePoint Solutions and Features

The STSADM command line application worked well with previous versions of SharePoint. But the world is progressing and PowerShell will be the new administrative tool for SharePoint. In previous articles, I already showed some amazing powerful scripts that otherwise would require more lines of code. PowerShell offers some great advantages in large farms, as they can be run remotely on target machines, can be signed and therefore be controlled. Building up a repository of scripts or cmdlets to execute common tasks would be worthwhile in the long run.

First off an important thing to note here that this will only work with SharePoint 2010. There are no PowerShell snapins available for 2007, although you could create your own off course. And when run from a SharePoint 2010 Management Shell, the snapins are loaded automatically. But what if you just use the ‘normal’ console? Well, then you would have to register the snapin yourself. Fortunately, MS has already created the PowerShell script that is needed, located at:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Config\PowerShell\Registration\SharePoint.ps1

You could include this script in your scripts to be run first, or just include the command that registers the snapin:
Add-PSSnapin Microsoft.SharePoint.PowerShell

This article covers one of the most basic tasks one would do when administrating SharePoint: Deploy SharePoint solutions (WSP) and enable/disable features.

Working with Solutions


In the ‘old’ days (let us not forget that the stsadm is still there and we have a lot of SharePoint 2007 installations across the globe), the following stsadm command could be used to add a SharePoint solution to SharePoint:
stsadm –o addsolution –filename “D:\Deploy\MySharePointSolution.wsp“

We used the following command to deploy the solution once installed to a specific web application:
stsadm –o deploysolution –name MySharePointSolution.wsp –url http://myspwebappp –allowgacdeployment –immediate

If we would upgrade an existing solution, we would use the following:
stsadm –o upgradesolution –name MySharePointSolution.wsp –filename “D:\Deploy\MySharePointSolution.wsp” -immediate

And finally, we used the following commands to retract and delete a specific solution from the web application:
stsadm –o retractsolution –name MySharePointSolution.wsp –url http://myspwebapp –immediate
stsadm –o deletesolution –name MySharePointSolution.wsp

Now, let us see how we could do above operations with PowerShell. For this, we use the following PowerShell commands:
Add-SPSolution “D:\Deploy\MySharePointSolution.wsp“
Install-SPSolution –Identity MySharePointSolution.wsp –WebApplication http://myspwebapp –GACDeployment

If you would like to add the solution as sandboxed, you would use the Install-SPUserSolution command instead. To upgrade a solution, we specify which solution is to be updated and with which new solution file:
Update-SPSolution –Identity MySharePointSolution.wsp –LiteralPath “D:\Deploy\MySharePointSolution.wsp” –GacDeployment

To retract and remove a solution, we use the following commands:
Uninstall-SPSolution –Identity MySharePointSolution.wsp –WebApplication http://myspwebapp
Remove-SPSolution–Identity MySharePointSolution.wsp

Working with features


Similarly, commands exist for working with features. The stsadm equivalents:
stsadm –o activatefeature –name MyFeatureName –url http://myspwebapp
stsadm –o deactivatefeature –name MyFeatureName –url http://myspwebapp

Needless to say, there are easy equivalents in PowerShell:
Enable-SPFeature –Identity MyFeatureNameOrGuid –url http://myspwebapp
Disable-SPFeature –Identity MyFeatureNameOrGuid –url http://myspwebapp

As you can see, PowerShell will completely replace stsadm as the administrative command line tool for SharePoint. Better to start using it as the next version of SharePoint will not have a stsadm command line tool I suspect. To conclude, let us take a look at a script that enables a certain feature across all site collections and sites in a farm. As an example, I have taken the SharePoint Server Enterprise Site Features feature with ID 0806d127-06e6-447a-980e-2e90b03101b8.
Add-PSSnapin Microsoft.SharePoint.PowerShell
$WebApplications = Get-SPWebApplication

foreach ($webapp in $WebApplications) {
  $Id = $webapp.Id
  Write-Host “Processing web application $Id …”
  $sites = $webapp.Sites
  foreach ($site in $sites) {
    Write-Host Processing site $site.Id
    $webs = $site.AllWebs
    foreach ($web in $webs) {
      Write-Host Processing web $web.Title
      if ($web.Features["0806d127-06e6-447a-980e-2e90b03101b8"] -eq $null) {
        Enable-SPFeature -Identity 0806d127-06e6-447a-980e-2e90b03101b8 -url $web.Url -Confirm:$false
      } else {
        Disable-SPFeature -Identity 0806d127-06e6-447a-980e-2e90b03101b8 -url $web.Url -Confirm:$false
      }
    }
  }
}

Please note though that above script will work for small site collections. But for larger object hierarchies, you will need to include proper memory management (SPAssignment) to ensure proper release of memory.

Friday, June 14, 2013

How to access user profile in Windows SharePoint Services + jquery

How to retrieve the SharePoint User profile in jQuery with use of SPServices.

Use below function for fetching the user information in jquery.

function getUserInfo(UserId){
wsBaseUrl = '/_vti_bin/';
var uiObj = {};
if(typeof(UserId)=="undefined" || UserId=='')UserId = _spUserId;
var arrOfFields = ['ID', 'Name', 'Title', 'EMail', 'Department', 'JobTitle', 'Notes', 'Picture',
'IsSiteAdmin', 'Created', 'Author', 'Modified', 'Editor', 'SipAddress', 'Deleted'];
var item = getItemById('UserInfo',UserId,arrOfFields);
    if(item != null){
        for(i=0;i<arrOfFields.length;i++){
            if(item[arrOfFields[i]]!=null){
                uiObj[arrOfFields[i]] = item[arrOfFields[i]];
            }else{
                uiObj[arrOfFields[i]] = '';
            }
        }
           return uiObj;
    }else{
        for(i=0;i<arrOfFields.length;i++){
            uiObj[arrOfFields[i]] = "User with id " + UserId + " not found.";
        }
        return uiObj;
    }
}

Tuesday, June 11, 2013

The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)

This problem is caused when another application runs on default port i.e. :80.

Most probably this issue occur because of Skype.

You can find the application which is running on that particular port by following command:

Open command prompt as administrator mode and type following command:
netstat -ano

This command list the process running on particular port. Please close that application and start your website from iis manager.

Now, You can able to access it as previously.

Monday, May 27, 2013

How To Set File Uplod Limit In SharePoint2010

By Default SharePoint2010 provides 50MB files to be upload to the server. If you want to extend upload size to server then you can do it in two ways.




  1. Through Central Admin: Navigate Central Admin -> Application Management -> Manage Web Application -> Select your web application -> General Setting. It contains Maximum Upload Size. Configure this to set maximum upload file limit. But you have to take care about the maxAllowedContentLength and maxRequestLength from the web.config file. To update web.config its very harmful if any other changes done in web.config so i preferred you use following command to set maximum upload file size.

  2. Using a SharePoint Management Shell: Open SharePoint Management Shell with Admin rights and fire the following command.



stsadm -o setproperty -propertyname max-file-post-size -propertyvalue <max-file-size (MB)> [-url http://server_name]


This command will configure your site as you mention the size in -propertyvalue.

Saturday, May 25, 2013

Create New Site Collection in the New Content Database in SharePoint2010

If you want to create a new site collection in the specific database, there are several different options available in the SharePoint 2010.

From the central administration site, you can create the site collection in the specific database with the following workaround. The downside of this approach is you have to temporarily take down the all the content databases in the given web application except the database where you want to create the new site collection.

  • Create a new content database for the given web application (Central Administration -> Manage Content Databases)

  • Detach/remove the content databases except the new one (Central Administration -> Manage Content Databases)

  • Create the new site collection from the central admin (Central Administration -> Create Site Collection)

  • Attach/Add the offline content databases (Central Administration -> Manage Content Databases)


Better way to approach creating the new site collection in the specific content database is to use New-SPContentDatabase and New-SPSite PowerShell commands.

  • Step 1- Add New Content DB to the Web Application


New-SPContentDatabase -Name WSS_Content_Accounts -WebApplication     http://demosite:55555


  • Step 2- Create New Site Collection with Top Level Site Based on Team Site Template in the New Content DB


New-SPSite http://demosite:55555/sites/accounts -OwnerAlias “Jaydoshi\Administrator” -ContentDatabase WSS_Content_Accounts -Name “Account Sites” -Description “Account Sites Container” -Template “STS#0″

Hope This is Hopeful to you..

Friday, May 24, 2013

Add Custom File Attachment Control in the Form of SharePoint

Normally SharePoint provides Document Attachment in the ribbon. But in my case ribbon was hide from the user. So I need to add Attachment Control on the form instead of ribbon. So I achieve it using Client Object Model. Insert the following code in your form to make attachment field available in the Form.
<tr>
<td rowspan="2" width="190px" valign="top" height="50px">
        <H3>
             Upload Evidence
        </H3>
     </td>
     <td valign="bottom" height="15" id="attachmentsOnClient">
         <span dir="ltr">
             <input type="file" name="fileupload0" id="onetidIOFile" size="56" title="Name" /> 
         </span>
     </td>
</tr>
<tr>
      <td colspan="4">
           <input id="attachOKbutton" type="BUTTON" onclick='OkAttach()' value="Upload" style="width: 12.8em; height: 2em"/>
           <span id="idSpace"/>
        </td>
</tr>

Thursday, May 23, 2013

How Value Return in Before Properties, After Properties and ListItem using EventReceiver in SharePoint2010

Event receivers are common in SharePoint development so its better to understand the data available in each events. Sometimes as a developer we jump into coding before thinking about contextual data availability.One more important thing to notice list event receiver  and document library event receiver are different items of contextual data availability.Following Table will give you a clear picture about the contextual data in each events.

  • SharePoint List























































Event



Before Properties Returns



After Properties Returns



ListItem Returns



Event Type



Item Adding



Null Value



New Value



Null Value



Synchronous



Item Updated



Null Value



New Value



New Value



Asynchronous



Item Updating



Null Value



Changed Value



Current Value



Synchronous



Item Updated



Null Value



Changed Value



New Value



Asynchronous



Item Deleting



Null Value



Null Value



Current Value



Synchronous



Item Deleted



Null Value



Null Value



Null Value



Asynchronous




  • SharePoint Document Library























































Event



Before Properties Returns



After Properties Returns



ListItem Returns



Event Type



Item Adding



Null Value



Null Value



Null Value



Synchronous



Item Updated



Null Value



Null Value



New Value



Asynchronous



Item Updating



Current Value



Changed Value



Current Value



Synchronous



Item Updated



Current Value



Changed Value



New Value



Asynchronous



Item Deleting



Null Value



Null Value



Current Value



Synchronous



Item Deleted



Null Value



Null Value



Null Value



Asynchronous


Get Field Values in ItemDeleting Event in SharePoint 2010

If you want to get value from a field in ItemDeleting event, you will need to call SPEventProperties.ListItem[“FIELD_NAME”].ToString() method. If you try to get a field value using AfterProperties or BeforeProperties properties, you will get System.NullReferenceException. The reason is these properties are only accessible in ItemUpdating or ItemUpdated events. An example of ItemDeleting event receiver is provider below:
try
{
string fieldValue = "";
fieldValue = properties.ListItem["FIELD_ID"].ToString();
}
catch (Exception ex)
{
properties.Cancel = true;
properties.Status = SPEventReceiverStatus.CancelWithError;
properties.ErrorMessage = ex.ToString();
}

Synchronous and Asynchronous Event Handlers

In SharePoint 2010 it is possible to handle events that occur on list items. These types of events come in two types: Synchronous and Asynchronous Event.

  • Synchronous: happens 'before' the actual event, you have the HttpContext and you can show an error message in the browser and cancel the event

  • Asynchronous: happens 'after' the actual event, there's no HttpContext  and you cannot directly show an error message or cancel the event


By sub-classing Microsoft.SharePoint.SPItemEventReceiver you can override the desired "event" methods.

  • Synchronous: methods ending with '-ing' (ItemAdding, ItemUpdating, ...)

  • Asynchronous: methods ending with '-ed' (ItemAdded, ItemUpdated, ...)


If you implement an override method you might want to place your code between the following lines to avoid raising other events unwantedly (and possibly causing an infinite loop).

this.DisableEventFiring(); 
...
this.EnableEventFiring();


Each override method has a parameter of type Microsoft.SharePoint.SPItemEventProperties that contains the item and event properties available for use. There's a bug in the SPItemEventProperties.AfterProperties dictionary that appears empty for synchronous events but it isn't. You can iterate over the dictionary to read and write to this collection ! This means that you can modify some of the inputted metadata before the actual item is stored in the list.

The thing to remember here is that the dictionary uses the field internal name as key, so field 'Field' could have an internal name such as 'My_x0020_custom_x0020_field'.

Friday, May 17, 2013

How to check member is exist in specific group in SharePoint2010 using javascript

In SharePoint 2010, if you want to check logged in user exists which particular group using javascript as follow:
function IsGroupMember(GroupName)
{
     var isGroupMember = false;
     $().SPServices(
     {
          operation: "GetGroupCollectionFromUser",
          userLoginName: $().SPServices.SPGetCurrentUser(),
          async: false,completefunc: function(xData, Status)
          {
               if($(xData.responseXML).find("Group[Name='" + GroupName + "']").length == 1)                
               {
                    isGroupMember = true;
               }
          }
     });
     return isGroupMember;
}

The above code returns the Group name of the logged in user.

You can use this function as:
if(IsGroupMember("Human Resources"))
{
//your code comes here
}

How to hide fields based in selection of radio button using java script

SharePoint generates a HTML code for the New/Edit/Display Page for each created list.

Now you have to the following java script code in your desire page to hide the field

Assume the html code is as follow:
<input type="radio" name="Internal Person" id="Person Type" value="ctl001">Internal Person</input> 
<input type="radio" name="External Person" id="Person Type" value="ctl002" >Invoiced</input>


The above code displays 2 radio button. Now you want to hide

var newVal = $(':radio[name=Reported By]:checked').val();
if (newVal == "ctl001")
{
       $('nobr:contains("Internal Reporter Name")').closest('tr').show();
       $('nobr:contains("External Reporter Name")').closest('tr').hide();
}
else
{
       $('nobr:contains("Internal Reporter Name")').closest('tr').hide();
       $('nobr:contains("External Reporter Name")').closest('tr').show();            
}

Friday, May 3, 2013

Getting error while creating a new web app saying "The password supplied with the domainname\username was not correct. Verify that it was entered correctly and try again"

When you create new web application at that time you enter your credential as the system account of the particular Web Application.

After that when you update your credential at that time you must have to update your credential in SharePoint also because SharePoint store your credential in SharePoint database.

To update your credential in SharePoint Database you must have to pass follow command in command prompt:

** Please open command prompt in Administrator mode.

  1. cd "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN" and press enter.

  2. stsadm -o updatefarmcredentials -userlogin <domain\username> -password <newpassword>


Once you update your credential in SharePoint database it will not effected directly so that you need to restart you IIS Web Server. For that following command will be fire in command prompt.

  1. iisreset /stop

  2. iisreset /start

Wednesday, May 1, 2013

Make Windows 8 Boot Directly To Desktop

Would you prefer to have Windows 8 bypass the Start Screen and boot straight to the desktop? If so, you can do so using a technique that takes advantage of a feature that is built right into the operating system - no third-party tools required. All you have to do is create a specially configured task that is scheduled to run at log on.

In this post, I’ll walk you through the steps required to make Windows 8 boot straight to the desktop using a specially configured scheduled task.

As you may recall, in previous versions of Windows, a special shortcut called Show Desktop appeared on the Quick Launch menu. This shortcut was a standard text file that contained five lines of code and was saved with the file extension SCF. The fifth line of that code wasCommand=ToggleDesktop.

To begin you’ll need to launch the Task Scheduler tool. To do so, just press the [Windows] key, type Schedule, select Settings, and click Schedule tasks, as illustrated in Figure A. When you do, the Task Scheduler will appear.

[caption id="attachment_3" align="alignnone" width="594"]Task Scheduler Task Scheduler[/caption]

Configuring Task

Once you have the Task Scheduler up and running, you’ll begin by clicking the Create Task command in the Actions panel, as shown in Figure B.

[caption id="attachment_4" align="aligncenter" width="594"]Create Task Command Create Task Command[/caption]

When the Create Task dialog box appears, you’ll see that the General tab is selected and will first assign the task a name in the Name text box. As you can see, I choose Show Desktop @ Start. Then, towards the bottom of the page, select Windows 8 from the Configure for drop down menu, as shown in Figure C. You can leave the Security options set to Run only when user is logged on.

[caption id="attachment_5" align="aligncenter" width="594"]Creating a Task Creating a Task[/caption]

To continue, select the Triggers tab to access that page, as shown in Figure D. Now, click the New button towards the bottom of the page.

[caption id="attachment_6" align="aligncenter" width="594"]Trigger Command Page Trigger Command Page[/caption]

When you see the New Trigger dialog box, select the At log on item from the Begin the task drop down menu, as shown in Figure E. As soon as you do, the New Trigger page will refresh and display the settings for the At log on option, as shown in Figure F.

[caption id="attachment_7" align="aligncenter" width="594"]When Command Triggered Selection When Command Triggered Selection[/caption]

[caption id="attachment_8" align="aligncenter" width="594"]Command Triggered when User Log On Command Triggered when User Log On[/caption]

By default, the Any user option in the Settings panel and the Enabled check box in the Advanced Settings are selected. Just leave them as they are and click OK to continue. When you return to the Create Task dialog box, select the Actions tab, as shown in Figure G. Then, click the New button towards the bottom of the page.

[caption id="attachment_9" align="aligncenter" width="594"]Command Action Command Action[/caption]

When you see the New Action dialog box, you’ll find that the Action setting is by default set to Start a Program. So, in the Settings panel, you can just type c:\Windows\explorer.exe in the Program/script text box, as shown in Figure H. You can also use the Browse button to locate and select the explorer.exe program. At this point, just click OK to return to the Create Task dialog box.

[caption id="attachment_10" align="aligncenter" width="468"]Specify Action Path Specify Action Path[/caption]

Now, IF you are running Windows 8 on a laptop, select the Conditions tab and in the Power panel, clear the Start the task on if the computer is on AC power check box, as shown in Figure I.

[caption id="attachment_11" align="aligncenter" width="594"]Creating a Task Creating a Task[/caption]

There is nothing that you need to change on the Settings tab so, at this point, you are done and can just click the OK button to complete the scheduled task operation. When you return to the Task Scheduler window, you’ll see the new task that you just created on the Task Scheduler Library, as shown in Figure J. You can now close Task Scheduler.

[caption id="attachment_12" align="aligncenter" width="594"]Schedule a Task Schedule a Task[/caption]

Your task is done now. When Windows 8 restarts, you’ll immediately see the Desktop with a File Explorer window targeted on Libraries, as shown in Figure M. You will not see the Start Screen at all.

(Keep in mind that when you see the File Explorer window targeted on Libraries, the Documents Music, Pictures, and Video icons may shuffle around a bit. The reason for this is because when the File Explorer window appears on the screen, the operating system is still doing a bit of housework in the background.)

[caption id="attachment_13" align="aligncenter" width="594"]Windows 8 Desktop Windows 8 Desktop[/caption]

Wednesday, April 24, 2013

First 9 things required to set as default setting in MS Word 2013

Everyone wants to work with latest software and make themselves upgraded with latest functionality. MS Office came up with 2013 version and it requires some default setting to make your document unchanged in other office version.

Now, the changes I make may not make sense for you and I am not suggesting that everyone do exactly what I do, but I am suggesting that you take a few minutes to adjust the default settings in MS Word 2013 to make it work the way you want it to work - at least as best you can. And, I mean before you starting using it, not after. A few minutes now can save you some frustration later.

Change the Normal Template

This suggestion is probably the most obvious and the most often overlooked. I don’t like the default font and spacing in Word. Personally I like the Arial font instead of Calibari and I like my paragraphs spaced evenly, so I change the default Normal Template (Figure A) right away.

Fig. A - The default Normal Template


Right-click the Normal Style in the Ribbon to get to the Modify Style options screen shown in Figure B. I change the font to Arial 10.

Fig. B - Change the Font


Fig. C - Change the Spacing


Click OK a few times to put the modifications into action. Remember to click the New documents based on this template radio button to make this your permanent Normal Template.


Word Options

This next set of modifications is very subjective - I make them because it makes my life as an editor easier. Reviewing the options may give you some ideas that will increase your productivity.

Formatting Marks

As an editor, I need to see every character on the page, even if the character is a blank space, so I always turn on all formatting marks. Click File in the menu bar and navigate down to the Options link to reach the Word Options configuration screen (Figure D). Click on the Display tab to reach the formatting marks settings. Click the Show all formatting marks check box.

Fig. D - Formatting Marks

Turn off Smart Quotes

Smart Quotes look great when you are in Word, but they don’t play well with WordPress and the other tools I have to use to publish content on TechRepublic, so I always turn them off. This is a two-step process, which makes it slightly tricky.

Under the Proofing tab you will see a button with the label: Auto Correct Options. When you click that button you are taken to the Auto Correct configuration screen. Click the Auto Format tab (Figure E) and deselect the Replace Straight quotes with smart quotes check box. For good measure, I also unchecked the boxes for Ordinals, Fractions, and Hyphens.

Fig. E - No Smart Quotes for me


Here is the slightly tricky part, you also have to look under the Auto Format As You Type tab and unchecked the appropriate check boxes under the Replace as you type category (Figure F). Click OK to apply the changes.

Fig. F - Also under replace as your type


Advanced Changes

One of the features Word employs to purportedly make our lives easier is called “smart” selecting. I hate it. I much prefer to select what I want to select without Word presuming I want a whole word or sentence or paragraph. Perhaps you like this feature, but it is not for me.

Under the Advanced tab of Word Options (Figure G), you will see several check boxes regarding selecting. I turn off selecting the entire word, and smart paragraph selection. I also typically click the check box that turns on Use Normal style for bullet-ed or numbered lists.

Fig. G - I prefer manual selection



This next change is really just for editing purposes, so it may not apply to you, but it is still good to know where the feature is located in case you ever need it. Further down the page under the Advanced tab there is an item that says: Style area pane width in Draft and Outline views (Figure H). I change that from zero to one inch. That change will reveal the style name used for each section of your document. Click OK to apply all of your changes.

Fig. H - Reveal your style

Quick Access Toolbar

As part of the ribbon interface, in the upper left corner, Word has a feature called the Quick Access Toolbar. However, the default configuration for that feature is, to put it politely, sparse: Save, Undo, and Redo.

While there are many tools and features to choose from when adding to the Quick Access Toolbar
(Figure I), I start with four obvious ones. No doubt, I will add more, as I am sure you will too.
  • Quick Print
  • Print Preview
  • Spelling & Grammar Check
  • Draft Mode
  • Save

Fig. I - Expand Selections on the quick access toolbar



Adding Quick Print, Print Preview and Spelling and Grammar is very simple: click the down arrow on the Quick Access Toolbar to reveal a list of potential tools and click the appropriate entries on the list.

Adding Draft mode is a little more complicated. There are several ways to accomplish the task, but the easiest way is to click the View tab (Figure J) and then right-click the Draft icon and select the Add to Quick Access Toolbar item.

Fig. J - Add Draft Mode

Set Zoom

The last thing I do depends on the display screen I am working on at the time. For large monitors, I change the Zoom factor to a higher percentage. The Zoom slider is located in the bottom right corner of you Word window. The default is 100%, but for 24 inch screens I typically bump this percentage to 180%. Click the 100% in that bottom right corner to get the Zoom configuration screen (Figure K) and change the percentage to 180. Or if you are good with the slider you can simply move it to your desired percentage.

Fig. k - Zoom to 180%

Bottom Line

None of the changes I have outlined are absolutely necessary, but for me, making these adjustments saves time, frustration, and headaches. The changes you make may not be the same as mine, but I am willing to bet, whatever changes to defaults you do make, are also made with the desire to save you time, frustration, and headaches.