Saturday, 19 October 2013

programmatically add edit delete in sharepoint list using c#

Add New Item :-
                   public void AddNewItem()
        {
            SPSecurity.RunWithElevatedPrivileges(delegate
            {
                using (SPSite site = new SPSite(SPContext.Current.Site.ID))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        SPList listEmpInsert = web.Lists["Employee"];
                        web.AllowUnsafeUpdates = true;
                        SPListItem EmpInsert = listEmpInsert.Items.Add();
                        EmpInsert["EmpName"] = "Mohamed";
                        EmpInsert["Age"] = "28";
                        EmpInsert["Address"] = "Chennnai";
                        EmpInsert.Update();
                        web.AllowUnsafeUpdates = false;
                    }
                }
            });
        } 
Update the Item:-
                        public void updateExistingItem()
        {
            SPSecurity.RunWithElevatedPrivileges(delegate
            {
                using (SPSite site = new SPSite(SPContext.Current.Site.ID))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        SPList lstupdate = web.Lists["Employee"];
                        web.AllowUnsafeUpdates = true;
                        int listItemId = 1;
                        SPListItem itemToUpdate = lstupdate.GetItemById(listItemId);
                        itemToUpdate["EmpName"] = "Mohamed sithik";
                        itemToUpdate["Age"] = "30";
                        itemToUpdate["Address"] = "Bangalore";
                        itemToUpdate.Update();
                        web.AllowUnsafeUpdates = false;
                    }
                }
            });
        }
Delete the Item
                           public void DelteItem()
        {
            SPSecurity.RunWithElevatedPrivileges(delegate
            {
                using (SPSite site = new SPSite(SPContext.Current.Site.ID))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        SPList lstdelete = web.Lists["Employee"];
                        web.AllowUnsafeUpdates = true;
                        int listItemId = 1;
                        SPListItem itemToDelete = lstdelete.GetItemById(listItemId);
                        itemToDelete.Delete();
                        web.AllowUnsafeUpdates = false;
                    }
                }
            });
        }
Get all the Item:-
              public void ReteriveallItem() 
        {
            SPSite mySite = new SPSite(SPContext.Current.Site.ID);
            SPWeb myWeb = mySite.OpenWeb();
            SPList myList = myWeb.Lists["Employee"];
            DataTable dt = ConvertSPListToDataTable(myList);
          
        }
        private static DataTable ConvertSPListToDataTable(SPList oList)
        {
            DataTable dt = new DataTable();
            try
            {
                dt = oList.Items.GetDataTable();
                foreach (DataColumn c in dt.Columns)
                    c.ColumnName = System.Xml.XmlConvert.DecodeName(c.ColumnName);
                return (dt);
            }
            catch
            {
                return (dt);
            }
        }



Thursday, 17 October 2013

we are having a problem opening this location in file explorer sharepoint 2013

Solution:-
            Just add the Desktop Experience

Refer the below link

http://www.win2012workstation.com/desktop-experience/

open with explorer sharepoint disabled

Solution:-

Just open the same Document in Internet Explorer(IE)

Friday, 11 October 2013

sign in different user missing in sharepoint 2013

1.Just open the following file

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\CONTROLTEMPLATES\Welcome.ascx

2.Add the below line inside the file

<SharePoint:MenuItemTemplate runat="server" ID="ID_LoginAsDifferentUser" 
Text="<%$Resources:wss,personalactions_loginasdifferentuser%>"  
Description="<%$Resources:wss,personalactions_loginasdifferentuserdescription%>"  
MenuGroupId="100"   Sequence="100"   UseShortId="true"   />





3. save it

Thursday, 10 October 2013

Rename ContentDataBaseName in SharePoint Using SQLQuery

Alter ContentDb Name
USE MASTER;
GO
ALTER DATABASE [WSS_Content_fdc3317e5897456ab294ef998ec46420]
SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE [WSS_Content_fdc3317e5897456ab294ef998ec46420]
MODIFY NAME= WSS_Content4;
GO
ALTER DATABASE WSS_Content4
SET MULTI_USER
GO

Delete SharePoint Content DataBase using PowerShell

Syntax:-

Remove-SPWebApplication http://sitename -Confirm -DeleteIISSite -RemoveContentDatabases

Example:-

Remove-SPWebApplication http://abcd01:1111/ -Confirm -DeleteIISSite -RemoveContentDatabases

Wednesday, 9 October 2013

move site collection from one web application to another web application using powershell

Example Script:-


#Get the from Site Collection URL
$fromURL = "http://Abcd:5000/sites/Fromsite"
#Get the to Site Collection URL
$toURL = "http://sfs01:4000/sites/Rsite3/"

#Location to the backup file directory to store Site Collection backup files
$backupPath = "C:\\SiteBK.bak"

#Backing up Site Collection prior to moving
Write-Host "Backing Up Site Collection…."
Backup-SPSite $fromURL -Path C:\SiteBK.bak -force

#Removing Site Collection from old web application path
Write-Host "Removing Site Collection from old managed path location…"
Remove-SPSite -Identity $fromURL -Confirm:$false

#Restoring Site Collection to new Managed Path
Write-Host "Restoring Site Collection to new managed path location…"
Restore-SPSite -Identity $toURL -Path c:\SiteBK.bak -Confirm:$false

#Remove backup files from the backup dirctory
Remove-Item c:\SiteBK.bak

delete sharepoint web application using powershell

Syntax:-
Remove-SPWebApplication "http://sitename" -Confirm -DeleteIISSite -RemoveContentDatabases

Example:-
Remove-SPWebApplication "http://Abcd:1111/" -Confirm -DeleteIISSite -RemoveContentDatabases

The Root Certificate that was just selected is invalid. This may be because the selected certificate requires a password

Solution:-
                  am using IE Browser its works for me...

Tuesday, 8 October 2013

Enable and Disable SharePoint Developer Dashboard with PowerShell

Enable:-

$devdash = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.DeveloperDashboardSettings;
$devdash.DisplayLevel = “OnDemand”;
$devdash.TraceEnabled = $false;
$devdash.Update()
Disable :-
 
$devdash = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.DeveloperDashboardSettings;
$devdash.DisplayLevel = “Off”;
$devdash.TraceEnabled = $true;
$devdash.Update()
 

SPgridviewpager Example using c#

Design Code:-

 <SharePoint:SPGridView ID="sgvPagersample" runat="server" AutoGenerateColumns="false" DataSourceID="objSample" AllowPaging="True" PageSize="3">
<Columns>
<asp:BoundField HeaderText="Employee ID" DataField="Title" />
<asp:BoundField HeaderText="Employee Name" DataField="EmpName" />
<asp:BoundField HeaderText="Employee Age" DataField="EmpAge" />
    <asp:BoundField HeaderText="Employee Salary" DataField="EmpSalary" />
</Columns>
</SharePoint:SPGridView>
    <asp:ObjectDataSource ID="objEmp" runat="server" SelectMethod="BindGridView"></asp:ObjectDataSource>
    <center>
    <SharePoint:SPGridViewPager id="sgvPager" runat="Server" GridViewId="sgvPagersample"></SharePoint:SPGridViewPager>
    </center>

Cs Code:-

  protected void Page_Load(object sender, EventArgs e)
        {
            objEmp.TypeName = this.GetType().AssemblyQualifiedName;
        }
        public DataTable BindGridView()
        {
            SPWeb currentWeb = SPContext.Current.Web;
            SPList lstEmployee = currentWeb.Lists["Employee"];
            SPQuery sQuery = new SPQuery();
            sQuery.Query = "<OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy>";
            SPListItemCollection myColl = lstEmployee.GetItems(sQuery);
            return myColl.GetDataTable();
        }

Monday, 7 October 2013

SharePoint People Picker with multi user

Design Code:-
 <table>
    <tr>
        <td>
       <SharePoint:PeopleEditor ID="PplMultiapp" runat="server" Width="250px" Height="25px" MultiSelect="true"/>
        </td>
        <td>
         <asp:Button ID="BtnMutiuser" runat="server" Text="AddMultiuser" OnClick="BtnMutiuser_Click" />
        </td>
    </tr>
</table>

Cs Code:-

 SPFieldUserValueCollection UserCollection = new SPFieldUserValueCollection();
            SPSite oSPsite = new SPSite(SPContext.Current.Site.ID);
            SPWeb oSPWeb = oSPsite.OpenWeb();
            SPList list = oSPWeb.Lists["PeopleList"];
            oSPWeb.AllowUnsafeUpdates = true;
            int iPeople = PplMultiapp.ResolvedEntities.Count;
            SPListItem oSPListItem = list.Items.Add();
            string[] UsersSeperated = PplMultiapp.CommaSeparatedAccounts.Split(',');
            foreach (string UserSeperated in UsersSeperated)
            {
                SPUser User = oSPWeb.SiteUsers[UserSeperated];
                SPFieldUserValue UserName = new SPFieldUserValue(oSPWeb, User.ID, User.LoginName);
                UserCollection.Add(UserName);
            }
            oSPListItem["Title"] = "Test Title";
            oSPListItem["user1"] = UserCollection;
            oSPListItem.Update();

SharePoint People Picker using c#

          <SharePoint:PeopleEditor ID="spPeoplePicker" runat="server" Width="350" SelectionSet="User" />

            SPSite oSPsite = new SPSite(SPContext.Current.Site.ID);
            SPWeb oSPWeb = oSPsite.OpenWeb();
            SPList list = oSPWeb.Lists["PeopleList"];
            oSPWeb.AllowUnsafeUpdates = true;
            int iPeople = spPeoplePicker.ResolvedEntities.Count;
             SPListItem itemToAdd = list.Items.Add();
            for (int i = 0; i < iPeople; i++)
            {
                PickerEntity peEntity = spPeoplePicker.ResolvedEntities[i] as PickerEntity;
                SPUser user = SPContext.Current.Web.EnsureUser(peEntity.Key);
                itemToAdd["Title"] = "Test Title";
                itemToAdd["User"] = user;  
                itemToAdd.Update();
            }

To Clear the PeoplePicker

            spPeoplePicker.Accounts.Clear();
            spPeoplePicker.Entities.Clear();

How to change web application port number in sharepoint

1.open "Centeral Administration" ----> "Manage web applications"
2.Select the "Webapplication"
3.Go to the ribbon control click the "Remove Sharepoint from IIS web site"
4.Click "yes"
5.Choose the same "webapplication"
6.Go to the ribbon control click the "Extend" button
7.Enter your Port no.

The password supplied with the username was not correct. Verify that it was entered correctly and try again

Solution:-
Go to command prompt and navigate to bin location of 15 hives
C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\BIN
stsadm -o updatefarmcredentials -userlogin <domainusername> -password <newpassword>
Reset the IIS

How to check the version in IIS

go to control panel
go to Administrative Tools
open IIS(internet Information services)
go to help menu and select About Internet Information Services
and there u can find your IIS version

Sunday, 6 October 2013

Get all library name in sharepoint using powershell


$s = Get-SPSite http://abcd:1111/sites/Demo1/
$wc = $s.AllWebs
foreach($w in $wc)
{
foreach($l in $w.Lists){
if($l.BaseTemplate -eq "DocumentLibrary")
{
Write-Host $l.Title"(Web: "$w.Title")"
}
}
}

Get all TableName and column name with datatypes in sql server

SELECT SysObjects.[Name] as TableName,
SysColumns.[Name] as ColumnName,
CASE SysTypes.[Name]
WHEN
'sysname'THEN
'nvarchar'
ELSE
SysTypes.[Name]
END
AS [Name]
,CASE SysTypes.[Name]
WHEN
'nvarchar'THEN
SysColumns.[Length] / 2
WHEN
'sysname'
THEN
SysColumns.[Length] / 2
ELSE
SysColumns.[Length]
END
AS [Length]
FROM
SysObjects INNER JOIN SysColumns
ON SysObjects.[Id] = SysColumns.[Id]
INNER JOIN SysTypes
ON SysTypes.[xtype] = SysColumns.[xtype]
WHERE SysObjects.[type] = 
'U'ORDER BY SysObjects.[Name

Friday, 4 October 2013

item level permission in SharePoint List

Solution:-

 1. Go to List setting.
 2. Click the Advance setting.
 In advance setting we have "Item-level Permissions" as one of option.
 This option have two sub options. For Read Access
 3. select "Read items that were created by the user"
 For Create and Edit access
 4.select "Create items and edit items that were created by the user"
 5.save the above settings.

SharePoint 2010 manage content and structure missing

Solutions:-

Step:-1

 Site actions
 Site settings
 Site collection administration
 Site collection features
 Activate this feature ‘SharePoint Server Publishing Infrastructure’

Step:-2

Site actions
Site settings-site actions
Manage site features
Activate this feature ‘SharePoint Server Publishing’

watermark example using jquery in asp.net

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript"
        src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js">
    </script>

    <style type="text/css">
        .water {
            font-family: Tahoma, Arial, sans-serif;
            color: gray;
        }
        .txtWidth {
            width: 200px;
        }
    </style>
    <script type="text/javascript">
        $(function () {

            $(".water").each(function () {
                $textbox = $(this);
                if ($textbox.val() != this.title) {
                    $textbox.removeClass("water");
                }
            });

            $(".water").focus(function () {
                $textbox = $(this);
                if ($textbox.val() == this.title) {
                    $textbox.val("");
                    $textbox.removeClass("water");
                }
            });

            $(".water").blur(function () {
                $textbox = $(this);
                if ($.trim($textbox.val()) == "") {
                    $textbox.val(this.title);
                    $textbox.addClass("water");
                }
            });
        });

    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div class="smallDiv">
            <h2>Watermark Example</h2>
            <br />
            <div>
                <asp:TextBox ID="txtUserName" class="water txtWidth" Text="User Name"
                    ToolTip="User Name" runat="server"></asp:TextBox><br />
                <br />
                <asp:TextBox ID="txtPassword" class="water txtWidth" Text="Password"
                    ToolTip="Password" runat="server"></asp:TextBox><br />
                <br />
            </div>
               <br />
            <br />
            <div>
                <asp:Button ID="btnSubmit" runat="server" Text="Login"  />
            </div>
            <br />
            <br />
        </div>
    </form>
</body>
</html>

Wednesday, 2 October 2013

Add Content editor web part in SharePoint 2010

1. Site Action
2. Edit Page
3. Editing Tools ->Insert
4. Web Part
5. Choose Media and Content Categories
6. Content Editor
7. Add


 Rename the Content editor web part in SharePoint 2010
1. Click the Content Editor
2. Edit Web Part
3. under Appearance
 4. Change the Title
5. Ok


Reduce the image size in Content editor

1. Site Action
2. Edit Page
3. Click the Content Editor
4. Edit Web Part
5. Double click the image
6. Picture tools will show in ribbon panel
7. Under Picture tools click Design
8. Then change the Horizontal Size and Vertical Size of the image
9. Save & Close


Add Link icon in Content editor

1. Site Action
2. Edit Page
3. Editing Tools ->Insert
4. Click the image
5. Click the link icon in the ribbon control Enter the Redirect url 

XML Data to CSV file using C#

Xml Code:-

<Employee>
  <Emp>
    <Name>Mohamed</Name>
    <Age>27</Age>
    <Salary>100000</Salary>
  </Emp>
  <Emp>
    <Name>Raja</Name>
    <Age>26</Age>
    <Salary>200000</Salary>
  </Emp>
  <Emp>
    <Name>uthaya</Name>
    <Age>30</Age>
    <Salary>450000</Salary>
  </Emp>
</Employee>

C# Code:-

MemoryStream ms = new MemoryStream();
            DataSet ds = new DataSet();
            ds.ReadXml(@"E:\Student.xml");
            if (ds.Tables[0].Rows.Count > 0)
            {
                StreamWriter writer = new StreamWriter(ms);
                writer.AutoFlush = true;

                foreach (DataColumn column in ds.Tables[0].Columns)
                {
                    writer.Write(column.ColumnName.ToString() + ",");
                }
                writer.WriteLine();

                foreach (DataRow Drow in ds.Tables[0].Rows)
                {
                    writer.Write(Drow["Name"].ToString() + "," + Drow["Age"] + "," + Drow["Salary"].ToString() + ",");
                    writer.WriteLine();
                }
            }
            using (FileStream file = new FileStream("E:\\Output.csv", FileMode.Create, FileAccess.Write))
            {

                ms.WriteTo(file);
            }

Monday, 30 September 2013

Programmatically get all listName in share point using C#

                  String SiteURL = "";
                  SPSite site = new SPSite(SiteURL);
                  SPWeb myWeb = site.OpenWeb();
                  foreach (SPList aList in myWeb.Lists)
                  {
                      string ListTitle = aList.Title;
                      //string rootName = aList.RootFolder.Name;
                  }

Programmatically get all site collection Name in share point using C#

           SPWebApplication webApp = SPWebApplication.Lookup(new Uri(WebApp));
            foreach (SPSite site in webApp.Sites)
            {
                SPWeb thisweb = site.OpenWeb();
                string WebName = site.Url;
                string templateName = thisweb.WebTemplate;
                site.Dispose();
            }

Programmatically get all web application Name in share point using C#

            get all webapplicationName      
            string strurls = "";
            SPWebApplicationCollection webapps = SPWebService.ContentService.WebApplications;
            foreach (SPWebApplication webapp in webapps)
            {
                string WebName = webapp.DisplayName;
                foreach (SPAlternateUrl url in webapp.AlternateUrls)
                {
                  strurls = url.Uri + "";
                }
             }

Friday, 27 September 2013

Download wsp file using powershell in sharepoint

$farm = Get-SPFarm
$file = $farm.Solutions.Item("collegeprojectvisualwebpart1.wsp").SolutionFile
$file.SaveAs("c:\collegeprojectvisualwebpart1.wsp")

Add deploy wsp sharepoint


Add Wsp to CentralAdmin
Add-SPSolution -LiteralPath "C:\Users\Administrator\Desktop\My Collection\Example.wsp"

Deploy to all Web application:-
Install-SPSolution –Identity “Example.wsp”  –AllWebApplications –GACDeployment

Retract all Webapplication:-
Uninstall-SPSolution –Identity Example.wsp –AllWebApplications

Remove wsp:-
Remove-SPSolution –Identity Example.wsp

Datatable Example in c#

            DataTable table = new DataTable();
            table.Columns.Add("EmpID", typeof(int));
            table.Columns.Add("EmpName", typeof(string));
            table.Columns.Add("EmpAge", typeof(int));
            table.Columns.Add("DOB", typeof(DateTime));

            //auto increment column
            DataColumn column = new DataColumn();
            column.DataType = System.Type.GetType("System.Int32");
            column.AutoIncrement = true;
            column.AutoIncrementSeed = 1;
            column.AutoIncrementStep = 1;
            table.Columns.Add(column);

            //Add Values to DataTables
            table.Rows.Add(1, "Mohamed", 27, new DateTime (1986,05,06));
            table.Rows.Add(2, "sithik", 26,new DateTime (1986,08,11));
            table.Rows.Add(10, "Raja", 25,new DateTime(1985,12,05));
            table.Rows.Add(11, "uthaya",30,new DateTime(1983,10,10));
            table.Rows.Add(12, "Ela", 28,new DateTime (1985,12,23));

            DataView view = new DataView(table);
            DataRow[] result = table.Select("EmpAge >= 20 AND EmpName = 'sithik'");
            DataTable dt1 = result.CopyToDataTable();

             DataView view = new DataView(table);
            view.RowFilter = "DOB > #1/1/1986#";
            view.Sort = "EmpAge Desc";

Get all list Name in SharePoint using Powershell


Get-SPWeb http://sfs01:1111/sites/Demo1/ |
Select -ExpandProperty Lists |
Select Title

Get System Domain Name using powershell

Get-WmiObject Win32_ComputerSystem

Thursday, 26 September 2013

update Site Column using Power shell in sharepoint

$site = Get-SPSite -Identity "http://abcd:1111/sites/Demo1/"
$web = $site.RootWeb
$field=$web.Fields["EmpName"]
$field.Type= "Choice"
$field.Update($true)
$web.Dispose()
$site.Dispose()

create Site Column Using Power shell in sharepoint

$site = Get-SPSite -Identity "http://abcd:1111/sites/Demo1/"
$web = $site.RootWeb
$fieldXML = '<Field Type="Text"
Name="EmpName"
Description="Employee Name Column Info."
DisplayName="EmpName"
Group="Clinic Site Columns"
Hidden="FALSE"
Required="FALSE"
ShowInDisplayForm="TRUE"
ShowInEditForm="TRUE"
ShowInListSettings="TRUE"
ShowInNewForm="TRUE"></Field>'
$web.Fields.AddFieldAsXml($fieldXML)
$web.Dispose()
$site.Dispose()

Creating Site Columns Programmatically through Elements.xml using all Datatypes

 <Field
       ID="{490f380c-ee51-41e1-8d7d-79aab5ca1d53}"
       Name="Clinic - Patient Name"
       DisplayName="Patient Name"
       Type="Text"
       Required="FALSE"
       Group="Clinic Site Columns">
  </Field>  <!--DataTypes = SingleLineText-->

  <Field
     ID="{FAD4C40B-A5B6-45A1-9C3D-D3494ABCA658}"
     Name="Clinic - Patient ID"
     DisplayName="Patient ID"
     Type="Number"
     Required="TRUE"
     Group="Clinic Site Columns">
  </Field>  <!--DataTypes = Integer-->

  <Field
     ID="{9A526521-3F1B-4AA9-B1E4-6F93C27A76F8}"
     Name="Clinic - Doctor Name"
     DisplayName="Doctor Name"
     Type="Text"
     Required="FALSE"
     Group="Clinic Site Columns">
  </Field>

  <Field
    ID="{02B25AC1-EBAA-464A-B543-829A033ADC58}"
    Name="Clinic - Doctor Address"
    DisplayName="Doctor Address"
    Type="Note"
    Required="FALSE"
    Group="Clinic Site Columns">
  </Field>      <!--DataTypes = Multiline-->

  <Field ID="{943E7530-5E2B-4C02-8259-CCD93A9ECB18}"
       Name="DoctorType"
       DisplayName="DoctorType"
       Type="Choice"
       Required="FALSE"
       Group="Clinic Site Columns" Format="Dropdown">
    <CHOICES>
      <CHOICE>Audiologists</CHOICE>
      <CHOICE>Allergist</CHOICE>
      <CHOICE>Andrologists</CHOICE>
      <CHOICE>Cardiologist</CHOICE>
      <CHOICE>Dentist</CHOICE>
      <CHOICE>Dermatologists</CHOICE>
    </CHOICES>
  </Field>     <!--ChoiceFormat = Dropdown-->

  <Field ID="{07BFA6D1-8730-4EAD-AEAD-428F0D924A12}"
       Name="DoctorTypeByRadioButton"
       DisplayName="DoctorTypeByRadioButton"
       Type="Choice"
       Required="FALSE"
       Group="Clinic Site Columns" Format="RadioButtons">
    <CHOICES>
      <CHOICE>Audiologists</CHOICE>
      <CHOICE>Allergist</CHOICE>
      <CHOICE>Andrologists</CHOICE>
      <CHOICE>Cardiologist</CHOICE>
      <CHOICE>Dentist</CHOICE>
      <CHOICE>Dermatologists</CHOICE>
    </CHOICES>
  </Field>
  <!--ChoiceFormat = RadioButton-->

  <Field ID="{1511BF28-A787-4061-B2E1-71F64CC93FD5}"
         Name="DateOpened"
         DisplayName="Date Opened"
         Type="DateTime"
         Format="DateOnly"
         Required="FALSE"
         Group="Clinic Site Columns">
    <Default>[today]</Default>
  </Field>    <!--DataTypes = DateTime-->

  <Field ID="{060E50AC-E9C1-4D3C-B1F9-DE0BCAC300F6}"
        Name="Amount"
        DisplayName="Amount"
        Type="Currency"
        Decimals="2"
        Min="0"
        Required="FALSE"
        Group="Clinic Site Columns" />

  <!--Rich Text HTML-->

  <Field ID="{13cd0291-df15-4278-9894-630913e4d2b9}"
   StaticName="AccrediterDescription"
   Name="AccrediterDescription"
   DisplayName="Accrediter_Description"
   Description="Accrediter Description of Item" Type="Note" NumLines="6" RichText="TRUE" RichTextMode="FullHtml" Group="Clinic Site Columns" />

  <!--HyperLink & Image-->
  <Field ID="{635a2031-2088-4413-b54e-d2af5daf08bf}"
   StaticName="ImageAuthor"
   Name="ImageAuthor"
   DisplayName="Image_Author"
   Description="Author Image" Type="URL" Format="Image" Group="Clinic Site Columns" />

  <!--YES/No Boolean-->
  <Field ID="{11018312-58f9-4eb0-867d-71298f82d98d}" Name="isActive" StaticName="isActive" DisplayName="isActive" Description="Select if Item is Active" Group="Clinic Site Columns" Type="Boolean">
    <Default>0</Default>
  </Field>

Friday, 23 August 2013

bind SharePoint discussion board reply in repeater using c#

Design code :-

<asp:Repeater ID="rptMain" OnItemDataBound="Repeater1_ItemDataBound" runat="server">
    <ItemTemplate>
        <h1><%#Eval("Title") %></h1>
        <asp:HiddenField  ID="hdnparentid" Value='<%#Eval("ID") %>' runat="server" />
        <asp:Repeater ID="rptChild" runat="server">
            <ItemTemplate>
                <asp:Literal ID="ltrchildbody" Text='<%#Eval("Body") %>' runat="server"></asp:Literal>
            </ItemTemplate>
        </asp:Repeater>
    </ItemTemplate>
</asp:Repeater>

Cs code:-

  protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem)
            {

                HiddenField hdnid = (HiddenField)e.Item.FindControl("hdnparentid");
                Repeater rptchild = (Repeater)e.Item.FindControl("rptChild");
                if (rptchild != null)
                {
                    using (SPSite site = new SPSite(SPContext.Current.Site.ID))
                    {
                        using (SPWeb web = site.OpenWeb())
                        {
                            SPList list = web.Lists.TryGetList("DiscussionList");
                            if (list != null)
                            {

                                SPFolder t = list.GetItemById(Convert.ToInt32(hdnid.Value)).Folder;
                                SPQuery q = new SPQuery();
                                q.Folder = t;
                                SPListItemCollection res = list.GetItems(q);
                                DataTable dt = new DataTable();
                                dt = res.GetDataTable();

                                rptchild.DataSource = dt;
                                rptchild.DataBind();
                            }
                        }
                    }

                   
                }

               
            }
        }
       public  void GetDisscussionTitles()
        {
            using (SPSite site = new SPSite(SPContext.Current.Site.ID))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPList list = web.Lists.TryGetList("DiscussionList");
                    if (list != null)
                    {
                        // Empty Query is passed to get only the discussion topics
                        SPListItemCollection itemColl = list.GetItems(new SPQuery());
                        DataTable dtmain = itemColl.GetDataTable();
                        rptMain.DataSource = dtmain;
                        rptMain.DataBind();

                    }
               }
            }
        }

Upload STP File to the List Template Gallery in SharePoint using PowerShell

    1.Click "Start" button
    2.Choose the "Microsoft SharePoint 2010 Products"
    3.Click the "SharePoint 2010 Management Shell" [ run as Administrator ]

Syntax:-

   $web = Get-SPWeb "SiteCollectionURL"
   $spFolder = $web.GetFolder("List Template Gallery")
   $spFileCollection = $spFolder.Files
   $file = Get-ChildItem "StpfilePath"
   $spFileCollection.Add("_catalogs/lt/StpFileName", $file.OpenRead(), $true)

Example:-
   
  $web = Get-SPWeb "http://Abcd/sites/SamSite"
  $spFolder = $web.GetFolder("List Template Gallery")
  $spFileCollection = $spFolder.Files
  $file = Get-ChildItem "C:\Users\Administrator\Desktop\Mohamed sithik\Employee.stp"
  $spFileCollection.Add("_catalogs/lt/Employee.stp", $file.OpenRead(), $true)

Thursday, 22 August 2013

how to get w3wp process id for a application pool in sharepoint

1. Open command prompt
2. Type the below commands and run it..


Syntax:-
             tasklist /M SolutionName.dll
Example:-
             tasklist /M SPF.Online.Exam.dll

error occured in deployment step add solution


Solution:-
              1.Reset the IIS

Monday, 19 August 2013

import Multiple files to SharePoint document library using powershell

Script:-

   if((Get-PSSnapin "Microsoft.SharePoint.PowerShell") -eq $null)
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell
}

#Script settings

$webUrl = "Site Collection URL"

$docLibraryName = "Documents"
$docLibraryUrlName = "Shared%20Documents"

$localFolderPath = "C:\temp\Docs4SharePoint"

#Open web and library

$web = Get-SPWeb $webUrl

$docLibrary = $web.Lists[$docLibraryName]

$files = ([System.IO.DirectoryInfo] (Get-Item $localFolderPath)).GetFiles()

ForEach($file in $files)
{

    #Open file
    $fileStream = ([System.IO.FileInfo] (Get-Item $file.FullName)).OpenRead()

    #Add file
    $folder =  $web.getfolder($docLibraryUrlName)

    write-host "Copying file " $file.Name " to " $folder.ServerRelativeUrl "..."
    $spFile = $folder.Files.Add($folder.Url + "/" + $file.Name, [System.IO.Stream]$fileStream, $true)
    write-host "Success"

    #Close file stream
    $fileStream.Close();
}

#Dispose web

$web.Dispose()

import excel data to sharepoint 2010 list using powershell

    1.Click "Start" button
    2.Choose the "Microsoft SharePoint 2010 Products"
    3.Click the "SharePoint 2010 Management Shell" [ run as Administrator ]

Script

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Read the CSV file - Map the Columns to Named Header (CSV File doesn't has Column Header)
$CSVData = Import-CSV -path "C:\Data.csv" -Header("Title", "Description")

#Get the Web
$web = Get-SPWeb -identity "Site Collection URL"

#Get the Target List
$list = $web.Lists["List Name"]

#Iterate through each Row in the CSV
foreach ($row in $CSVData)
{
$item = $list.Items.Add();
$item["Title"] = $row.Title
$item["Description"] = $row.Description
$item.Update()

Tuesday, 13 August 2013

save list as custom template using PowerShell

Powershell Script:-

              $site = get-spsite("http://abcd:12312/sites/Sample/")
              $web = $site.RootWeb
              $list = $web.Lists["MyCustomListName"]
              $list.SaveAsTemplate("MyCustomListTemplate.stp",                                                                                   "MyCustomListTemplate","MyCustomList Template", $false)
              $listTemplates = $site.GetCustomListTemplates($web)
              $web.Lists.Add("MyCustomNewList", "My CustomNew List",                                                                               $listTemplates["MyCustomListTemplate"])

Note:-
             http://abcd:12312/sites/Sample/=site collection url
             MyCustomListName =CustomList Name
             MyCustomListTemplate.stp =stp file Name




How to count the the total number of item in Sharepoint list using Powershell

powershell script :-

      $spWeb = Get-SPWeb "http://abcd:12312/sites/Sample/"
      $spList = $spWeb.Lists["MysampleCustomList"]
      $spListItems = $spList.Items
      Write-Host $spListItems.Count

Note:-

    http://abcd:12312/sites/Sample/ =Site collection url
    MysampleCustomList = ListName
     

How to Check if your SharePoint 2010 Web Application Uses Claims Authentication



$web = Get-SPWebApplication "http://abcd:12312/sites/Sample"
$web.UseClaimsAuthentication

Note:-
   http://abcd:12312/sites/Sample =site collection url

How to Import the Multiple file to SharePoint Document Library using PowerShell

if((Get-PSSnapin "Microsoft.SharePoint.PowerShell") -eq $null)
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell
}

#Script settings

$webUrl = "http://abcd:12312/sites/Sample"

$docLibraryName = "Documents"
$docLibraryUrlName = "Shared%20Documents"

$localFolderPath = "C:\temp\Docs4SharePoint"

#Open web and library

$web = Get-SPWeb $webUrl

$docLibrary = $web.Lists[$docLibraryName]

$files = ([System.IO.DirectoryInfo] (Get-Item $localFolderPath)).GetFiles()

ForEach($file in $files)
{

    #Open file
    $fileStream = ([System.IO.FileInfo] (Get-Item $file.FullName)).OpenRead()

    #Add file
    $folder =  $web.getfolder($docLibraryUrlName)

    write-host "Copying file " $file.Name " to " $folder.ServerRelativeUrl "..."
    $spFile = $folder.Files.Add($folder.Url + "/" + $file.Name, [System.IO.Stream]$fileStream, $true)
    write-host "Success"

    #Close file stream
    $fileStream.Close();
}

#Dispose web

$web.Dispose()

Note:-

    http://abcd:12312/sites/Sample = site collection url

Monday, 5 August 2013

sharepoint 2010 disable i like it tags and notes

1.open "Central Administration" and choose the "System settings"
2.click the "Manage Farm Features"
3. then find the "Social Tags and Note Board Ribbon Controls"
4.click the DeActivate and then Click the "DeActivate this Features"

the document could not be opened for editing. a windows sharepoint services compatible application

solution:-
            am using Mozila FireFox latest version  its works for me

Enable/Disable Delete Option of List in Sharepoint 2010 using Powershell

Script:-

If ((Get-PSSnapIn -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{
Add-PSSnapIn -Name Microsoft.SharePoint.PowerShell
}

$web = Get-SPWeb -Identity "http://ABCD:12312/sites/Sample/" -AssignmentCollection $assignment
$list = $web.lists["TestList1"]
$list.AllowDeletion = $false
$list.Update()


Note:-

 http://ABCD:12312/sites/Sample/ = site collection url
TestList1 = List Name

Sunday, 4 August 2013

programmatically upload file to document library in sharepoint 2010



Code:-

using (SPSite site = new SPSite(SPContext.Current.Site.ID))
  {

using (SPWeb web = site.OpenWeb())
  {

SPSecurity.RunWithElevatedPrivileges(delegate()
               {

SPDocumentLibrary documentLib = web.Lists["Shared Documents"] as SPDocumentLibrary;

Stream fStream = FileUpload1.PostedFile.InputStream;
byte[]  _byteArray = new byte[fStream.Length];
fStream.Read(_byteArray, 0, (int)fStream.Length);
fStream.Close();

web.AllowUnsafeUpdates = true;

string _fileUrl = documentLib.RootFolder.Url + "/" + FileUpload1.PostedFile.FileName;

bool IsOverwriteFile = true;
SPFile file = documentLib.RootFolder.Files.Add(_fileUrl, _byteArray, IsOverwriteFile);

SPListItem item = file.Item;
item["Title"] = FileUpload1.PostedFile.FileName;
item.Update();
file.Update();

web.AllowUnsafeUpdates = false;
             
      });          
 }
     
 }

Thursday, 1 August 2013

Reterive a list of checkout file in sharepoint 2010 site collection using powershell

Script:-

$webAppURL = "Enter your Web application Url"

function ReportCheckedOutItems() {
    $webapp = Get-SPWebApplication $webAppURL

    foreach ($site in $webapp.Sites)
    {
        write-host "Site Collection: $($site.Url)"
        $allwebs = $site.allwebs
        foreach($web in $allwebs)
        {
            $count = 0
            write-host "--Site: $($web.Url)"
            foreach ($list in ($web.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})) {
                Write-Host "-----List: $($list.RootFolder.ServerRelativeUrl)..."
                foreach ($item in $list.CheckedOutFiles)
                {
                    if (!$item.Url.EndsWith(".aspx"))
                    {
                        continue
                    }
                    write-host "File: $($item.Url) - checked out by $($item.CheckedOutBy)" -ForeGroundColor Red
                    $count++
                }
                foreach ($item in $list.Items)
                {
                    if ($item.File.CheckOutStatus -ne "None")
                    {
                        if (($list.CheckedOutFiles | where {$_.ListItemId -eq $item.ID}) -ne $null)
                        {
                            continue
                        }
                        write-host "File: $($item.Url) - checked out by $($item.CheckedOutBy)" -ForeGroundColor Red
                        $count++
                    }
                }
            }
            if ($count -gt 0)
            {
                write-host "Found $count checked out files for site $web" -ForeGroundColor Red
            }
        }
    }
}

ReportCheckedOutItems