Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Monday, March 04, 2013

Live Task Print data from GridView using JQuery




Explanation:-
  1. Keep your GridView in one Div or TD.
  2. Give some ID for that Div or TD.
  3. For using JQuery Download the latest plugin & use it.
  4. Place the GridView in the Div or TD which you had given ID and follow the code in ascx file.
Ascx
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="GridViewContentPrintUserControl.ascx.cs" Inherits="GridViewContentPrint.GridViewContentPrint.GridViewContentPrintUserControl" %>
<script language="javascript" type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script language="javascript" type="text/javascript">
    function printGridViewData()
    {
        var prtContent = $("#divPrint");
        var WinPrint = window.open('', '', 'letf=0,top=0,width=100,height=100,toolbar=0,scrollbars=0,status=0');
        WinPrint.document.write(prtContent.html());
        WinPrint.document.close();
        WinPrint.focus();
        WinPrint.print();
        WinPrint.close();
    }
</script>
<div style="text-align:center;"><input id="btnPrint" type="button" value="Print" onclick="Javascript:printGridViewData();" /></div>
<div id="divPrint">
<asp:GridView ID="dgvTasksPrint" runat="server" AutoGenerateColumns="False"
        Width="100%" CellPadding="4" EnableModelValidation="True" ForeColor="#333333"
        GridLines="Both">
    <AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField HeaderText="Title" DataField="Title" />
<asp:BoundField HeaderText="Status" DataField="Status" />
<asp:BoundField HeaderText="Priority" DataField="Priority" />
<asp:BoundField HeaderText="Start Date" DataField="StartDate" DataFormatString="{0:G}" />
<asp:BoundField HeaderText="End Date" DataField="DueDate" DataFormatString="{0:G}" />
</Columns>
    <EditRowStyle BackColor="#2461BF" />
    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
    <RowStyle BackColor="#EFF3FB" />
    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
</asp:GridView>
</div>
Ascx.cs
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using System.Security;

namespace GridViewContentPrint.GridViewContentPrint
{
    public partial class GridViewContentPrintUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    getData();
                }
            }
            catch (Exception Ex)
            {
                Response.Write(Ex.ToString());
            }
        }

        public void getData()
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                SPListItemCollection myColl = SPContext.Current.Web.Lists["Tasks"].Items;
                if (myColl.Count > 0)
                {
                    dgvTasksPrint.DataSource = myColl.GetDataTable();
                    dgvTasksPrint.DataBind();
                }
            });
        }
    }
}

New Features in SharePoint 2013

Hi All,

Please download the the PDF & Word Document from the below links which are given in http://learningsharepoint.com.

Download 101 New Features in SharePoint 2013 (Pdf)

Download 101 New Features in SharePoint 2013 (Doc) 

Click here to read the complete article from Learning SharePoint Blog.

Sunday, March 03, 2013

Using SharePoint Objects within a Server Side Linq




Ascx
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="LinqWithOutLoopUserControl.ascx.cs" Inherits="LinqWithOutLoop.LinqWithOutLoop.LinqWithOutLoopUserControl" %>
<asp:GridView ID="dgvLinqWithOutLoop" runat="server"
    AutoGenerateColumns="False" Width="100%" CellPadding="4"
    EnableModelValidation="True" ForeColor="#333333" GridLines="Both">
    <AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField HeaderText="ID" DataField="ID" />
<asp:BoundField HeaderText="Title" DataField="Title" />
<asp:BoundField HeaderText="Department" DataField="Department" />
<asp:BoundField HeaderText="Age" DataField="Age" />
<asp:BoundField HeaderText="Country" DataField="Country" />
<asp:BoundField HeaderText="Joining Date" DataField="Joiningdate" DataFormatString="{0:G}" />
<asp:BoundField HeaderText="Favourite Color" DataField="FavouriteColor" />
<asp:BoundField HeaderText="Author Name" DataField="AuthorName" />
<asp:BoundField HeaderText="Change Age" DataField="ChangeAge" />
</Columns>
    <EditRowStyle BackColor="#2461BF" />
    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
    <RowStyle BackColor="#EFF3FB" />
    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
</asp:GridView>
Ascx.Cs
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using System.Security;
using System.Linq;

namespace LinqWithOutLoop.LinqWithOutLoop
{
    public partial class LinqWithOutLoopUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                getData();
            }
            catch (Exception Ex)
            {
                Response.Write(Ex.ToString());
            }
        }

        public void getData()
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
               string Title, Department, Age, Country, Joiningdate, FavouriteColor, AuthorName, ChangeAge, ID = string.Empty;
               var strQuery = (from SPListItem item in SPContext.Current.Web.Lists["Employees Data"].Items
                                orderby item.ID descending
                                select new
                                {
                                  Title = item.Title.ToString(),
                                  Department = item["Department"].ToString(),
                                  Age = item["Age"].ToString(),
                                  Country=new SPFieldLookupValue(item["Country"].ToString()).LookupValue,
                                  Joiningdate = item["Joiningdate"].ToString(),
                                  FavouriteColor = item["FavouriteColor"].ToString(),
                                  AuthorName = (item["AuthorName"] == null) ? "--" : new SPFieldLookupValue(item["AuthorName"].ToString()).LookupValue,
                                  ChangeAge = (item["ChangeAge"] == null) ? "0" : item["ChangeAge"].ToString(), ID=item.ID.ToString()
                                });
                dgvLinqWithOutLoop.DataSource = strQuery;
                dgvLinqWithOutLoop.DataBind();
            });
        }
    }
}

Friday, March 01, 2013

SharePoint 2013 Notes



  1. Delete this site option is removed by Microsoft at top level site.
  2. In Quick Launch Recycle Bin is removed.
  3. Sign in as Different user option is removed (We can configure this at server level).
  4. List is renamed to App in SharePoint 2013.
  5. Document set is improved in SharePoint 2013 as a result we can create many Document Sets inside the Document Set or even inside the folder. Default Breadcrumb doesn’t work fine in SharePoint 2010 after using Document Set is created. And the Folder inside the Document Set in SharePoint 2010 is also treated as an file. Now all these things had been set right by Microsoft in SharePoint 2013.
  6. Recent is introduced in SharePoint 2013 Quick Launch. As a result we can see what are the recent lists or libraries opened.

Another way to Find Recycle Bin in SharePoint 2013

 
  1. Login to your SharePoint site.
  2. Click on settings icon next to your UserName.
  3. In Settings Icon click on Site Settings.
  4. Under Site Collection Administration section you will find Recycle Bin.
  5. Click on it you can go to Recycle Bin page.