How to add WORD (PDF file Search) in Search Navigation in SharePoint 2013

               In SharePoint 2013 Enterprise search center preview searches nearly everything SharePoint crawls. That’s why its search results are labelled “Everything”.







            
     But for specialized scenarios, you often want a specialized search experience to match.

Example: People takes you to people search, returns only people results, responds intelligently to certain people-related queries such as searches for a mail id, phone no..
Build a simple search experience for word, for that we have to create “Result Source” and “Search Result Web Part”.

      Search Experience = Result Source + Search Results Web Part.
                      
Create a word Result source

   First, we have to create a Result Source that only returns word results. From your enterprise search center, go to site settings -> search -> Result Sources, Click on New Results 





















            Click on New Result source


      It shows window like this, we have to follow these steps.

·                         “Word” is the source name.
·                             “Result with file extension” is the description of source.
·                             Keep the protocol on “Local SharePoint”, because we want item crawled by SharePoint.
·                             Keep the type on “SharePoint Search Results”, we don’t want people results.
·                             Query Transform: “{searchTearms} fileextension:pdf”.
               

       Click “OK”, we have created our “Word result source”



Create a Search Results Web Part

    Go to search center, click the gear icon, choose New Page (or) Go to site contents-> pages in ribbon add page give it a name "Word".


           Click create, we create word page. Word is the Search Result Web Part. Default it sends user queries to the local SharePoint Results source. We need to change it so that it sends quires to our word Results source instead.

      Open word page and in gear icon choose “Edit page”, in search result heading next, click the little arrow next to the checkbox that appears select edit web part.



It brings Web Part tool pane. We want to change the query that this web Part sends, so click to change Query button.



            We only need a very simple transformation: the Web Part should transform queries so that they go to a different Result Source. So pick word Results from the Result Source drop down


Click "OK" on the Query Builder, then "OK" on the Web Part’s tool pane, and finally publish your changes to the page.



Fleshing Out Your Search Experience

        Now add our "Word" Search to the Search Navigation, next to People, Conversations, and the other standard search experiences.
Go to Site Settings -> Search -> Search Settings.


     Now we configure Search Navigation links. Click on "Add Link" 



           We have to give title “Word”, then click Browse and pick the search page we created earlier(Word page).
.
Click “OK” to save link, select it and click “Move Up”.


  Finally Click “Ok”, try to search in search center. You’ll see a link to  your Word search, and clicking it will search just docx files.
















How to get the current Site collection Url in SharePoint using JavaScript.

How to get the current Site collection Url in SharePoint using JavaScript.
 In this Article I will explain how to get the current site collection url in sharepoint using java script

<script type="text/javascript">
var currentsiteurl = "<%= SPContext.Current.Site.Url %>";
</script>


Now we are getting the site collection in currentsiteurl variable.
We can call this variable in JavaScript based on our condition 

filtering in spgridview in sharepoint

In this article I will explain how to create filtering in spgridview.
Take Visualwebpart,in managementUserControl.ascx write the following code.
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce222e9429c" %> 
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce222e9429c" %> 
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce222e9429c" %>
<%@ 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=71e9bce222e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="managementUserControl.ascx.cs" Inherits="Webparts.management.managementUserControl" %>

    
      
        No Data Found
    

In managementUserControl.ascx.cs write the following code.
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web;
using Microsoft.SharePoint;
using System.Data;
using System.ComponentModel;

namespace Webparts.management
{
    public partial class managementUserControl : UserControl
    {
        public static DataTable table = new DataTable();
       
        public static string ddllist;
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {

              
                if (!IsPostBack)
                {
                    
                    
                    gridBind();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

               public void gridBind()
        {

            spgrid.DataBind();
        }

        public static DataTable getData()
        {
           
            SPWeb currentWeb = SPContext.Current.Web;
            SPList lst = currentWeb.Lists["ListName"];
            table = lst.GetItems().GetDataTable();
           
                      return table;
        }
}
}
Finally OutPut:

How to bind spgridview in sharepoint

How to bind spgridview in sharepoint
In this Article I will explain how to bind the SPGridView in SharePoint.


public void bindSPGrid()
        {
            SPWeb currentWeb = SPContext.Current.Web;
            SPList list = currentWeb.Lists["ListName"];
            SPListItemCollection myListColl = list.Items;
            if (myListColl.Count > 0)
            {

                spgridview.DataSource = myListColl.GetDataTable();
                spgridview.DataBind();
        }
            }

Don’t forget to call this method in
PageLoad

how to populate dropdownlist values from list in sharepoint

how to populate dropdownlist values from list in sharepoint

I created a ListDefination through VS2010 Name PopulateDropDown, In this I written code in Elements.xml

<Field Type="Choice"
DisplayName="Ticket"
Required="TRUE"
Group="PopulateDropDown Group"
ID="{E48F775E-1263-44A0-8B1C-39C7A2A4EDCF}"
StaticName="Severity"
Name="Ticket">
<CHOICES>
<CHOICE>Select</CHOICE>
<CHOICE>High</CHOICE>
<CHOICE>Medium</CHOICE>
<CHOICE>Low</CHOICE>
</CHOICES>
</Field>

and Schema.xml.

These values will display in List in Sharepoint.
But I have to populate these values in UserControl ascx page .



<div>
Ticket
<asp:DropDownList ID="ddlticket" runat ="server" >
</asp:DropDownList>

</div>

Now I am writing code to populate values in this dropdown list in ascx.cs
 public void ddlLoadTicket()
        {
            SPSite ositecollection = SPContext.Current.Site;
            using (SPWeb owebsiteroot = ositecollection.OpenWeb())
            {
                SPList list = owebsiteroot.Lists["PopulateDropDown"];
                SPFieldChoice field = (SPFieldChoice)list.Fields["Ticket"];
                ddlseverity.DataSource = field.Choices;
                ddlseverity.DataBind();
                }

                 }




Don't forget to call this method in PageLoad.


Finally you get the Result......

How to get Content Type Id in SharePoint list

Get Perticular list Contenttype Id  

Go to Site contents open your list ,here i am opening my "project" list




Navigate to the ribbon -> List -> select "List Settings"




Navigate to "Advanced Settings" 




check "yes" on Allow management of content types on clock "Ok"



Now "Content Types" is available in  list settings. click on "Item" content type


It shows Project list "Content Type Id"








How to create rdlc reports in asp.net

In this Article I will explain how to create RDLC Reports in ASP.Net.
Finally my output looks like this.


I created a table with name Employee


Now I am creating an empty web application as shown


Right click on the solution add Report Wizard as shown below.

After adding report wizard, we have to configure Data source as shown, I am selecting my database.

Click Next->Next
Select the Database objects, I am selecting my table name and stored procedure name as shown ,Click Finish.

It displays dataset properties click Next

Drag the available fields 

Click Next->Next->Next->Finish.

Finally rdlc Design will display like this.

Now I am creating a web form with name Report.aspx, click Add

Now I am designing my UI as shown

  Drag the report viewer  and choose Report as our report name as shown  

Drag the script manger on the UI Screen.
Finally my UI looks as shown.

We can find the Report.aspx code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Report.aspx.cs" Inherits="RdlcExample.Report" %>

<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
     <div>
        <label>Name</label>
       <asp:DropDownList ID="ddlname" runat="server">
         <asp:ListItem>All</asp:ListItem>
        </asp:DropDownList>
        <label>Designation</label>
        <asp:DropDownList ID="ddldesignation" runat="server">
         <asp:ListItem>All</asp:ListItem>
        </asp:DropDownList>
        <label>Address</label>
        <asp:DropDownList ID="ddladdress" runat="server">
         <asp:ListItem>All</asp:ListItem>
        </asp:DropDownList>
        <br />
        <asp:Button ID="btnReport" runat="server" Text="GenerateReport"
            onclick="btnReport_Click" />

   
    </div>
    </div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"
        Font-Size="8pt" InteractiveDeviceInfos="(Collection)"
        WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
        <LocalReport ReportPath="Report1.rdlc">
            <DataSources>
                <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" />
            </DataSources>
        </LocalReport>
    </rsweb:ReportViewer>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
        SelectMethod="GetData"
        TypeName="RdlcExample.Report">
    </asp:ObjectDataSource>
    </form>
</body>

</html>


    


    
All All All
Now I am implementing the Logic for generating report in Report.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

namespace RdlcExample
{
    public partial class Report : System.Web.UI.Page
    {

        static DataTable DatTab { get; set; }
        //DataSet dt 
        public static string Name { get; set; }
        public static bool flag { get; set; }
        public static SqlConnection con = new SqlConnection("Data Source=CHINNU;Initial Catalog=dotnetdb;User ID=sa;Password = password123;");
        public static string Designation { get; set; }
        public static string Address { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                loadDdlDesignation();
                loadDdlAddress();
                loadDdlName();
                GetData();
              

            }
        }
        public void loadDdlAddress()
        {

            try
            {
               
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }

                SqlCommand com = new SqlCommand("select EmpAddress from Employee", con); 
                SqlDataAdapter da = new SqlDataAdapter(com);
                DataSet ds = new DataSet();
                da.Fill(ds);  

                ddladdress.DataTextField = ds.Tables[0].Columns["EmpAddress"].ToString(); 

                ddladdress.DataSource = ds.Tables[0];
                ddladdress.DataBind();
                ddladdress.Items.Insert(0, "All");
            }
            catch (Exception)
            {


            }


        }
        public void loadDdlDesignation()
        {

            try
            {
               
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }

                SqlCommand com = new SqlCommand("select EmpDesignation from Employee", con); // table name 
                SqlDataAdapter da = new SqlDataAdapter(com);
                DataSet ds = new DataSet();
                da.Fill(ds);  // fill dataset
                ddldesignation.DataTextField = ds.Tables[0].Columns["EmpDesignation"].ToString(); // text field name of table dispalyed in dropdown

                ddldesignation.DataSource = ds.Tables[0];      //assigning datasource to the dropdownlist
                ddldesignation.DataBind();  //binding dropdownlist
                ddldesignation.Items.Insert(0, "All");
            }
            catch (Exception)
            {


            }


        }



        public void loadDdlName()
        {

            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }


                SqlCommand com = new SqlCommand("select EmpName from Employee", con); 
                SqlDataAdapter da = new SqlDataAdapter(com);
                DataSet ds = new DataSet();
                da.Fill(ds);  

                ddlname.DataTextField = ds.Tables[0].Columns["EmpName"].ToString(); 

                ddlname.DataSource = ds.Tables[0];      
                ddlname.DataBind();  
                ddlname.Items.Insert(0, "All");
            }
            catch (Exception)
            {


            }


        }
        public static DataTable GetData()
        {
            try
            {
                
                DatTab = new DataTable();
                
                if (!flag)
                {
                    SqlCommand cmd = new SqlCommand("select  * from Employee", con);
                    //cmd.CommandType = CommandType.StoredProcedure;
                    SqlDataAdapter adap = new SqlDataAdapter(cmd);
                    adap.Fill(DatTab);
                    con.Close();
                }

                else
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    using (SqlCommand cmd = new SqlCommand("Show_Report", con))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@EmpName", SqlDbType.NVarChar)).Value = Convert.ToString(Name) == "All" ? "-1" : Convert.ToString(Name);
                        cmd.Parameters.Add(new SqlParameter("@EmpDesignation", SqlDbType.NVarChar)).Value = Convert.ToString(Designation) == "All" ? "-1" : Convert.ToString(Designation);
                        cmd.Parameters.Add(new SqlParameter("@EmpAddress", SqlDbType.NVarChar)).Value = Convert.ToString(Address) == "All" ? "-1" : Convert.ToString(Address);

                        cmd.ExecuteNonQuery();
                        SqlDataAdapter da = new SqlDataAdapter(cmd);
                        da.Fill(DatTab);
                        con.Close();
                    }
                }
                con.Close();
            }
            catch (Exception ex)
            {
                con.Close();
            }
            return DatTab;
        }

        protected void btnReport_Click(object sender, EventArgs e)
        {
            flag = true;
            Designation = ddldesignation.Text.Trim();
            Address = ddladdress.Text.Trim();
            Name = ddlname.Text.Trim();



            GetData();

            ReportViewer1.LocalReport.Refresh();
        }
    }
}
After completing all the steps Press F5 .

OutPut:




Web parts maintenance page If you have permission, you can use this page to temporarily close Web Parts or remove personal settings. For more information, contact your site administrator.

An unexpected error has occurred.

 Web parts maintenance page If you have permission, you can use this page to temporarily close Web Parts or remove personal settings. For more information, contact your site administrator.

I added visual web part in my VS2010. I written some code and deployed, once deploy successes.

I am trying to open web part page URL. If faced this error as shown.
My web part page url is
 Then add Web part page url will be
 Now you are able to delete that particular web part.
 Generally this issue will come because of our code errors,now we want to debug the code for that.
Go to the web config navigation C:\inetpub\wwwroot\wss\VirtualDirectories\14343

Open the web file and find for
call stack and customerror mode
change call stack = “true” and customerror mode = “Off”

Now we can get a beautiful  error which we can able resolve our issue.