In many scenarios, we may need to allow users to select files from the document library. In such cases, we will prefer to display the contents i.e. files in a Tree View, so that it would be easy for users to select them. So now, we will see how to display the folders/files in Tree View in an ASPX page (we might show in pop up window).
First, create an empty SharePoint project and map the Layouts folder. In that, add an application page to it. Name the page as TreeView.aspx.
Open the TreeView.aspx page design part and add an ASP place holder to hold the ASP Tree View control to the page.
So, the code in page design will look like the following:
- <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
- <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
- <%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
- <%@ Import Namespace="Microsoft.SharePoint" %>
- <%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TreeView.aspx.cs" Inherits="TestProject.Layouts.PopUp.TreeView" DynamicMasterPageFile="~masterurl/default.master" %>
- <asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server"> </asp:Content>
- <asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
- <asp:Label Text="Please select the document(s) from the Tree" runat="server"></asp:Label> <br />
- <asp:placeholder id="placeHolder" runat="server" /> </asp:Content>
- <asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server"> Tree View Doc Lib </asp:Content>
- <asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server"> Tree View Doc Lib </asp:Content>
We can create a function ( createTree ) to load the Tree View. This function should be called in the OnInit function of the page.
The code will look like the below snippet:
- protected override void OnInit(EventArgs e) {
- base.OnInit(e);
- createTree();
- }

goran ljubicPosted May 11, 2017, 3:14 AM
Hi i used link https://www.macaw.nl/artikelen/extreme-new-document-button-makeover for display document library on application page but i have a problem. can you ask some questions?
Tarun DPosted Aug 9, 2016, 10:43 AM
Nice Share Siva..