Wednesday, December 3, 2014

Uninstall the WSP solution from SharePoint farm using Poweshell

Introduction

Normally, we are uninstall and remove the wsp from farm manually. Here i am sharing powershell script for this


$SPfarm = [Microsoft.SharePoint.Administration.SPFarm]::get_Local()



$solution = "SolutionName.wsp";
#Getting solution id
$currentSolution = $SPfarm.get_Solutions() | Where-Object { $_.DisplayName -eq $solution; }
$sol_file = $currentSolution.id

$spSolution = GET-SPSolution -Identity $sol_file
if ($spSolution.ContainsWebApplicationResource)
{
    $spSolution | UnInstall-SPSolution -AllWebApplications -Confirm:$false
}
else
{
    $spSolution | UnInstall-SPSolution -Confirm:$false
}

do { Start-Sleep -Seconds 1; Write-Host "Waiting for undeployment..." } while ($spSolution.DeploymentState -ne [Microsoft.SharePoint.Administration.SPSolutionDeploymentState]::NotDeployed)

Write-Host "Waiting for timer job to complete. " -ForegroundColor Yellow
Start-Sleep -Seconds 30

# Remove solution from solution store
Remove-SPSolution –Identity $sol_file -confirm: $false

Write-Host "Solution undeployed!" -ForegroundColor Green

Tuesday, December 2, 2014

Retrieve details of solution using powershell script

Introduction

Here i am going to share the script for show the details of solution which is deployed in the farm

$SPfarm = [Microsoft.SharePoint.Administration.SPFarm]::get_Local()

# What Solution are we looking for?
$solution = "Solutionname.wsp";

# Get the solutions
$currentSolution = $SPfarm.get_Solutions() | Where-Object { $_.DisplayName -eq $solution; }
$currentSolution;

Adding “Everyone” Permissions Programmatically in SharePoint 2013

Introduction

Normally, we are having permission level operations in SharePoint. We may assign such kind of permission both manually and programmatically. Here, we will see how to give permission to "Everyone" programmatically

Code


SPUser allUsers = web.AllUsers[@”c:0(.s|true”]; //c:0(.s|true is Everyone
SPRoleDefinitionCollection roleCollection = web.RoleDefinitions;
SPRoleDefinition roleDefinition = roleCollection[“Visitors”];

SPRoleAssignment roleAssignment = newSPRoleAssignment((SPPrincipal)allUsers);
roleAssignment.RoleDefinitionBindings.Add(roleDefinition);

list.BreakRoleInheritance(false);
list.RoleAssignments.Add(roleAssignment);

list.Update();

Powershell script

Set-SPUser -Identity "c:o(.s\true" -web "webUrl" -Group "Visitors"

Wednesday, November 26, 2014

Delete webparts from Webpart Gallery

Introduction

We may came across the situation to remove all the custom webparts while feature deactivating. Here we are going to see how to remove the webparts programmatically.

Code

Paste the below code in FeatureDeactivating method

  SPSite site = properties.Feature.Parent as SPSite;
            if (site != null)
            {
                var definedElements = properties.Definition.GetElementDefinitions(CultureInfo.InvariantCulture);
                var allFiles = definedElements.Cast<SPElementDefinition>()
                    .SelectMany(x => x.XmlDefinition.ChildNodes.Cast<XmlElement>()
                        .Where(f => f.Name.Equals("File"))
                        .Select(f => f.Attributes["Url"].Value)).ToList();
                var webPartGallery = site.RootWeb.Lists["Webpart Gallery Name"];

                var webPartsToDelete = webPartGallery.Items.Cast<SPListItem>()
                    .Where(w => allFiles.Contains(w.File.Name)).ToList();

                for (var index = webPartsToDelete.Count - 1; index >= 0; --index)
                {
                    var webPartItem = webPartsToDelete[index];
                    webPartItem.Delete();
                }
            }

Tuesday, November 25, 2014

Delete folder from Catalog masterpage

Introduction

We may came across this situation to delete a folder in catalog master page when you deactivating feature. Here we are going to see, how can we delete this kind of folder programmatically

Code

using (SPSite site = new SPSite(siteUrl))
{
 SPList listCatalog = site.GetCatalog(SPListTemplateType.MasterPageCatalog);
                site.AllowUnsafeUpdates = true;
                SPFolder masterpageFolder = listCatalog.RootFolder.SubFolders["FolderName"];
                if (masterpageFolder != null)
                {
                    masterpageFolder.Delete();
                }
                site.AllowUnsafeUpdates = false;
                site.RootWeb.Update();
}

Friday, November 14, 2014

Join This Community Button Not visible on Community Site


In some case we may faced this issue in community site. To enable this button select "Enable Auto-Approval" in Community Settings. 

Note: This option available when Community site is in root site. This Feature will applicable for subsites of Community root site.


Wednesday, October 15, 2014

Set Search and Offline Availability programmatically

Introduction

As all we know SharePoint is having an option to search a content through out the site. We can able to skip some sites in search crawling. Normally, we can do this manually in the site.
Goto Site Settings --> Search and Offline Availability and set option as you want.

Let see, How can we set this programmatically.

Code

var contextWeb = SPContext.Current.Web;
contextWeb.AllowUnsafeUpdates = true;
contextWeb.AllowAutomaticASPXPageIndexing = false;
contextWeb.ASPXPageIndexMode = WebASPXPageIndexMode.Never;
contextWeb.NoCrawl = true;
contextWeb.Update();
contextWeb.AllowUnsafeUpdates = false;

Monday, October 13, 2014

Applying site policy programmatically in SharePoint 2013

Introduction

We all know that about Site Closure and deletion. Click here to know some notes about it. Here, i am going to give an idea to apply this site policy to subsites programmatically. After setting Site Closure and Deletion follow the below instructions.

Site Policy

Refer  Microsoft.Office.RecordsManagement.InformationPolicy dll in your project and inherit this in the page

using Microsoft.Office.RecordsManagement.InformationPolicy;

var contextWeb = SPContext.Current.Web;
 contextWeb.AllowUnsafeUpdates = true;

ProjectPolicy groupPolicy = (from s in ProjectPolicy.GetProjectPolicies(contextWeb.Site.OpenWeb()) where s.Name == "Your Sit Policy Name" select s).FirstOrDefault();
                ProjectPolicy.ApplyProjectPolicy(contextWeb, groupPolicy);
contextWeb.Update();
contextWeb.AllowUnsafeUpdates = false;

That's all Site Policy will apply in your site. To ensure that, Goto Site Closure and Deletion in Site Settings and check applied Site Policy.

Tuesday, October 7, 2014

Set Property value for a Site Programmatically

Introduction

Property bag is having property with their Key and Value. Its used to keep value and used it within a site. It will be used across the subsites, If we set a property in Main site collection. Let see how to set this property programmatically.

Set Property

var web = SPContext.Current.Web;
web.AllowUnsafeUpdates = true;
web.Properties.Add("Key", "Value");
web.Properties.Update();
web.AllowUnsafeUpdates = false;

//Get a Property value
var r = SPContext.Current.Web.Properties["Your Property Key"]

Tuesday, September 23, 2014

Site Closure and Delete policy in SharePoint 2013

Introduction

We have an option to set a policy to close and delete for SharePoint sites. Let we see what are all the steps involves for the same.

Site Policy

Site policy is like a definition which covers all the protocols of closure and deletion. We need to set this in Site Collection. Policies will available in sub sites once it defined in top level site. Steps to set Site Policy,

  • Goto Site Settings in Top Level Site
  • Click Site Policy in Site Collection Administrations

  • Choose Create to set up a policy
  • Fill up the options of new site policy 

  • Here, I given example to delete a site automatically. The Site will be deleted after 4 days of site creation. We will get an Email notification 1 day before and it is having an option to follow up by Email. We may postpone the deletion for a specific period if site admin wants to extend. Postpone period also set up here. Once you done with option click Ok. Policy has created and list out in Site Policies.

Site Closure and Deletion

After policy set up is done. We need to inherit this policy in sub sites. Then only our site will be deleted automatically as per policy. Here is the steps to apply the policy

  • Goto Site Settings in your subsite
  • Click Site Closure and Deletion in Site Administration
  • Here, The policies will populate in Site Policy Dropdown. We have to choose the policy from Dropdown and Click Ok. Once you applied the policy, It will show up, when you site is going to delete and Enable the postpone option if you set in Policy. 

That's all Site Closure and Deletion has applied for your site. Your site will be Closed/Deleted as per Site Policy.

Sunday, September 21, 2014

Set Owner for a Group in SharePoint site programmatically

Introduction

As all we know, We have an option to keep group with set of people in SharePoint. This group is having some permission to access the site. Generally, We have three groups in a site like Owner, Contributor and Visitor. Owners having rights to do all in site. Contributor is allowing to access the site with limited permission. Visitor is having rights to just visit a site.
We may set an owner to these groups. By default, It will take Site Collection admin as an Owner of the group. Let us see how to modify that programmatically.

Customization

var groupName = SPContext.Current.Web.Groups["YourGroupName"];
groupName.Owner = "UserName"; //Give as SPUser
groupName.Update();
SPContext.Current.Web.Update();

That's all group owner has set to the group.

Wednesday, September 17, 2014

Referring CSS in Application Page

We may get confused to refer a css in application page. That is, Where it should be placed. Because, It will show an error if we placed the css wrong place.

Here the correct place to refer

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <link href="Your css URL" rel="Stylesheet" id="linkStyle" runat="server" type="text/css" />

</asp:Content>

Tuesday, September 16, 2014

Set Target Audience for a webpart programmatically

Introduction

As all we now SharePoint webpart properties having an option to set Target Audience. If we set this to particular member/group, the webpart will show to them. Let we see how to set this by programmatically

Customization

At First, we need to create a site page and add a webpart in it programmatically using visual studio. Refer this URL to add an webpart in sitepages. Then add an Event receiver to Feature. call  the below method in Feature Activating method

 private void SetTargetAudienceToAdmin(SPFeatureReceiverProperties properties, string relativeUrlOfPage)
        {
            
            try
            {
                var web = properties.Feature.Parent as SPWeb;
                
                    using (web)
                    {
                        web.AllowUnsafeUpdates = true;
                        SPFile page = web.GetFile(web.Url + "/" + relativeUrlOfPage);
                        if (page.Exists)
                        {
                            SPServiceContext serviceContext = SPServiceContext.GetContext(web.Site);
                            AudienceManager audienceManager = new AudienceManager(serviceContext);
                            SPLimitedWebPartManager wpManager = web.GetLimitedWebPartManager(page.Url, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
                            foreach (System.Web.UI.WebControls.WebParts.WebPart wp in wpManager.WebParts)
                            {
                                if (wp.Title.ToLower().Equals("YourWebpartTitle"))
                                {

                                        wp.AuthorizationFilter = string.Format("{0};;;;", Your GroupName/UserName);
                                        wpManager.SaveChanges(wp);
                                   
                                }

                            }
                        }
                        web.Update();
                        web.AllowUnsafeUpdates = false;
                    }

            }
            catch (Exception ex)
            { throw ex; }
        }

Tha's all. Audience has set to Your webpart.


Wednesday, September 3, 2014

Delete subsites within site collection using Powershell

Here i am going to give a script to delete all the webs within site collection. The script,

Get-SPSite  Your site collection URL| Get-SPWeb -Limit All | ForEach-Object {Remove-SPWeb -Identity $_ -Confirm:$false}

This script will access the rootweb also but it can't be deleted. To avoid this, try the below

$url = " Your site collection URL"
$subsites = ((Get-SPWeb $url).Site).allwebs | ?{$_.url -like $url +"/*"}


foreach($subsite in $subsites) { Remove-SPWeb $subsite.url }

Wednesday, August 27, 2014

Site Pages library is missing in SharePoint site

We may face "SitePages list doesn't exist" issue while activating feature. To resolve this problem, We need to activate "Wiki Page Home Page" feature.


Tuesday, August 26, 2014

Showing Image Popup while clicking images in NewsFeed Webpart

Introduction

I already given some ideas about Newsfeed webpart. Now, I am going to give an idea to show image popup when we click an image in NewsFeed.


Customization

Here too we can do the customization newsfeed webpart in both Direct and Programmatic way. 

Direct

After placing Newsfeed webpart in sitepage, Then, Upload a jquery library in Site Assets. Download the plugins here Add a Script Editor webpart in same page. Edit the Script Editor and paste below script.

<script type="text/javascript" src="/SiteAssets/jquery.min.js"></script>
<script type="text/javascript" src="/SiteAssets/jquery.popupoverlay.js"></script>

<script type="text/javascript">

$('.ms-microfeed-attachmentImage').addClass('feedPopup_open'); //adding class to image
 $('#feedPopup').popup(); 
//On click method for an image

 $('.ms-microfeed-attachmentImage').click(function () {

        var image_href = $(this).attr("src"); //getting image source
        $('#divFeedDescPopup').html('<img src="' + image_href + '" />'); //appending an image with popupblock
    });

</script>


<!-- Style for popup -->

<style>
.popupContent p label {
    display: block;
    font-weight: bold;

}
.popupContent img {
    width:100%;

}
</style>

<!-- Popup block -->
<div id="feedPopup" class="popupBlock" style="width: 30%; display: none">
<div id="divFeedDescPopup" class="popupContent"> </div>
 <button class="feedPopup_close popupClose">Close</button>
</div>


That's all save the page. Popup will display for each images in newsfeed webpart.

Programmatically

Add a sitepage in your solution within module. And paste the jquery library files in _layout folder. Then, Refer those library files in sitepage. Paste the above script, style and popup block in the page. Deploy the solution and see the popup while clicking an image in Newsfeed.


Setting Row Limit in CAML Query

Here, I am going to give an example to set RowLimit for list items in CAML Query.

Query

<View>
<Query>
<OrderBy>
                                    <FieldRef Name="Created" Ascending='FALSE'/>
</OrderBy>
</Query>
<ViewFields>
<FieldRef Name="ID"/>
<FieldRef Name="Title"/>
<FieldRef Name="Job_x0020_Title"/>
<FieldRef Name="Email_x0020_ID"/>
<FieldRef Name="Member_x0020_Name"/>
</ViewFields>
<RowLimit Paged="TRUE">1</RowLimit>

</View>

Sunday, August 17, 2014

Applying ellipsis in NewsFeed Content

Introduction

As all we know we have NewsFeed webpart to display our activities in Mysite. The NewsFeed contents are not applied with ellipsis style. So, the content height will get enlarge automatically. Here, i am going to share an idea to apply ellipsis for content.

NewsFeed Webpart

First, We need to place the newsfeed webpart in our page. The method is our choice whether it may be applied directly or programmatically. If you need to go with programmatically, Click here

Cutomization

Customization will differ based on way we chose to place the webpart directly / programmatically in the page. Let we see both customization here.

Directly

First place the Newsfeed webpart in sitepage. Then, upload the jquery library in Site Assets. 
Add ScriptEditor in the page. Open the ScriptEditor and place the below script.

<script type='text/javascript' src="/SiteAssets/jquery.min.js"></script>
<script type='text/javascript'>
$(document).ready(function ($) {
$('.ms-microfeed-replyText span').addClass('replyEllipsis');

 $(.ms-microfeed-replyText span').click(function () {
        if ($(this).hasClass('replyEllipsis')) {
            $(this).removeClass('replyEllipsis')
        }
        else {
            $(this).addClass('replyEllipsis')
        }

    });
});
</script>

CSS for replyEllipsis

<style> .replyEllipsis {
    width:250px;
    overflow: hidden;
    -ms-text-overflow: ellipsis;
    text-overflow:ellipsis;
    white-space: nowrap;
  }
</style>

Here, I did code for ellipsis for reply text in Newsfeed. I have found <div> tag of reply container, they form <span> for reply text. I am getting <span> and added new class in it. Already made css for that class (replyEllipsis). The jquery has added the class in <span> tag at page load. And i did toggle type of code to apply ellipsis for reply text (ON/OFF).

Programmatically

Add the <script> in the sitepage and paste the above script. Deploy the solution. The Ellipsis will apply in Newsfeed webpart.

Wednesday, August 13, 2014

Changing list view properties in Listview webpart Programmatically

Introduction

As well know about views in Lists and Listview webpart which is used in sitepages/pages. Here i am going to share an idea about changing views of listview webpart programmatically.

ListView Webpart

We can use listview webpart to display and edit list items in Sitepage/Page. It displays information in different ways for different purpose such as filtering, sorting / selecting specific columns. Its a short note about listview webpart. Now, Let's see how to add list view webpart programmatically.

Adding Listview Webpart


Changing properties of view in Listview Webpart

We are going to access the webparts in a page using SPLimitedWebPartManager. Then, Get the webpart by using condition check with webpart title. Convert the webpart as XsltListViewWebPart. Take view from it and change as we want. For instance, I have changed the number of rows in listview. 


  web.AllowUnsafeUpdates = true;

        XsltListViewWebPart webPart = null;
        SPLimitedWebPartManager wpManager = SPContext.Current.Web.GetLimitedWebPartManager("your page name", System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
foreach (System.Web.UI.WebControls.WebParts.WebPart wp in wpManager.WebParts)
        {
          if (wp.Title.Equals("Webpart title"))
                    {
webpart = wp as XsltListViewWebPart;
var currentView = webPart.View;
                currentView.RowLimit = Convert.ToUInt32(3);
                currentView.Update();
                web.AllowUnsafeUpdates = false;

}
}

This is code to change row limit. we may change some of the properties in View. That's it.

Wednesday, August 6, 2014

Adding Wiki Page in SharePoint Programmatically

Introduction

As we all know wiki page is one of the concept in SharePoint to add content at run time. Let's see how to add this wiki page programmatically.

Wiki Page 

At first, Create new SharePoint Project in Visual studio with one feature file. Then, Create an Event Receiver for feature. Paste the below code in FeatureActivated method.

  using (SPSite site = new SPSite(webUrl))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPList list = web.Lists["Site Pages"];
                    web.AllowUnsafeUpdates = true;
                    SPFolder rootFolder = list.RootFolder;
                    SPFile wikiPage = SPUtility.CreateNewWikiPage(list, String.Format("{0}/{1}", rootFolder.ServerRelativeUrl, "your page name"));
                    SPListItem wikiItem = wikiPage.Item;
                    wikiItem["WikiField"] = "content";
                    wikiItem.Update();
                    web.AllowUnsafeUpdates = false;
                }
            }

Just deploy the solution in your site and activate the feature to see created Wiki page.



Happy Coding.. !!!!

Tuesday, August 5, 2014

Showing My Site's Newsfeed in SharePoint Web Application Programmatically

Introduction

 In My Site (SharePoint 2013), We have an option to track our activity using News Feed webpart. This webpart will show all the activities of logged in person in Mysite. Let see the note about Newsfeed webpart


NewsFeed

NewsFeed is the user's social hub where user can see the updates from people, documents, sites and tags which is followed by user. It displays the feeds of recent activities related to a user's specified interests. User can customize their interest by adding (Follow) / removing (Unfollow) colleagues, tags and documents.

This is short note about NewsFeed webpart. Let's see how we can integrate this into normal SharePoint site collection programmatically.

After the creation of farm solution using visual studio. Just add your sitepage under SitePages module.


Add Microsoft.SharePoint.Portal Reference


Then, Register portal dll in created sitepage.

<%@ Register TagPrefix="Portal" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

Paste the MicroFeedwebpart at where you want to display it within page. This webpart is used to get the feeds which is in My Site Newsfeed

<Portal:MicroFeedWebPart runat="server" id="sfwNewssFeed" ChromeType="none"></Portal:MicroFeedWebPart>  

That's all. Deploy your solution in SP web application. Newsfeed will display in SitePage.


Monday, August 4, 2014

Configure User Profile in SharePoint Farm

Introduction

I am going to share an idea to configure the User profile in Farm solution. Let see

Web Application

At first, Create a new web application for My Site with "Mysite Host" site collection. This web application will be act as My site once all configuration is done.

Set "Personal" to define managed path for created web application. Steps are,
  • Select the created new web application under Manage Web Applications
  • Then, Click Managed Paths at top ribbon
  • Add "Personal" as New path and click OK




User Profile Config 

Do the following configuration steps,
  • Browse your Central Admin site
  • Click Manage service applications under Service Applications category
  • Create New User profile service if you do not have for it. 
  • Click New at top ribbon, then choose User Profile Service in drop down menu
  • Give a name for New User Profile Service Application and click Create
  • we may find created service application in Manage service application category
  • We will get the properties of Service once you clicked that
  • There we have option to click Setup Mysite under My Site Settings
  • Here, we will have lot of properties regarding my site. Give your My site host web application url in My Site Host option
  • Give permission to Everyone; All Users(Windows) in Read Permission Level option and click Ok at bottom
  • Then, Need to Review job definition in Monitoring --> Timer Jobs. Because, all feeds about users will get populate when this timer job is run at once



  • We will see the list of jobs. Select User Profile Service with Activity Feed job suffix (For ex: User Profile Service App - Activity Feed job

  • We may get Edit timer job properties once we clicked Review job definition
  • It shows 10 minutes by default. If you want change the time limit, do it. otherwise let it be and click Run Now

That' all. User Profile has configured in your SP farm

Sunday, August 3, 2014

Deploying WSP using Powershell Script

Introduction

I am to share the Powershell script which is use to deploy the wsp.

Script

Follow the below steps to create ps1 file

  • Open a notepad and paste this script

try
{
    Write-Host "Please make sure that ""SharePoint Administration"" and ""SharePoint Timer Service"" are running and then Press a key to proceed with installation.."
    $pressedKey = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

    $currentLocation = Get-Location
    $solutionPath = "Give path of wsp with wsp file"

    #Step 1: Add WSP to solution store
    Write-Host "Adding solution to solution store.. " -ForegroundColor Yellow
    $spSolution = Add-SPSolution $solutionPath

    #Step 2: Deploying the solution to required web application
    #$webApplication = Read-Host "Please enter my site web application url to which solution needs to be deployed (Eg. http://<yourserver:port): "
    Write-Host "Deploying" $spsolution.Name ".." -ForegroundColor Yellow
    Install-SPSolution -Identity $spSolution.Name -GACDeployment

    #Step 3: Waiting for deployed status
    do
    {
        Start-Sleep -Seconds 1
        Write-Host "Waiting for Deployed status.."
    }while(-not($spSolution.Deployed))

   
    #Step 4: Completing installation
    
    Write-Host "wsp installation successful!!!" -ForegroundColor Green

}
catch
{
    Write-Host "Following is the error occurred while executing this script -->" $_
}


  • Then, save the text file with .ps1 extension
  • This is it, just run the powershell script file to deploy the wsp

Wednesday, July 16, 2014

Add ListView in SitePages using BinarySerializedWebPart

Introduction

I am going to share my idea about showing listview in sitepages using BinarySerializedWebPart. Let's see the steps for the same.

Save site as Site Template 

At first, Create a site and Create a list which you need to show in site page. Be sure about column names and view your going to show. For Example: If you want to show Name list in your site. Create a Name list in test site with same column. The steps are,
  • Create a list with needed columns (Ex: Name list)
  • Create any views for list if you want
  • Create one sitepage and insert this list webpart in the page
  • Then, Go to Site Settings --> Save site as Template
  • Give the File Name of template and click OK


  • We may get the success message if its done properly




Import Site Template

Go to Solution Gallery and download the template file in your local disk. Then, Import the wsp using Visual Studio. Steps are,

  • Create a SharePoint 2013 - Import Solution Package Project 
  • Choose Farm level  in Security level debugging window


  • Then, Browse the downloaded package and place it in Specify the new project source window and click Next
  • If you want to import particular items. then, select the items in Select item to import window. Otherwise Click Finish (All items has checked by default)
  • It will take sometimes to import the package. We may get the success message once its done. Then Click Ok

Paste BinarySerializedWebPart

Copy the BinarySerializedWebPart from imported solution and paste it on your SitePage's element.xml. Steps are,

  • Go to List Instance module in Solution Explorer, we may find SitePages list there
  • Then, We may get SitePages_1033_STS_doctemp_smartpgs when expanding SitePages list
  • Expand the SitePages_1033_STS_doctemp_smartpgs and open Element.xml



  • In Element.xml, we may find all sitepages with <File> tag.
  • Find the SitePage which is having listwebpart (Ex: I have put listview in test sitepage)
  • Copy the <view> tag of listview fully
  • Paste it in SitePages's Element.xml where you want show this listview
  • Change the WebPartZoneID and WebPartOrder as sitepage have.

  • That's all. Deploy your original solution in farm.  We may see the listview in sitepage where we pasted it.