4
Answers

application page in visual studio

goran ljubic

goran ljubic

7y
290
1
i'm bigginer. i used site https://www.macaw.nl/artikelen/extreme-new-document-button-makeover for creating application page which will open when someone click on button. i create button in ribbon, bu when i click on button, application page is opening with error
 
  1. The method or operation is not implemented.   
  2. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.   
  3.   
  4. Exception Details: System.NotImplementedException: The method or operation is not implemented.  
  5.   
  6. Source Error:   
  7.   
  8. An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.    
  9.   
  10. Stack Trace:   
  11.   
  12.   
  13. [NotImplementedException: The method or operation is not implemented.]  
  14.    NOVODUGME.Layouts.NOVODUGME.TemplateSelector.SetTemplateLibraryFolders() +72  
  15.    NOVODUGME.Layouts.NOVODUGME.TemplateSelector.Page_Load(Object sender, EventArgs e) +107  
  16.    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25  
  17.    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42  
  18.    System.Web.UI.Control.OnLoad(EventArgs e) +132  
  19.    Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase.OnLoad(EventArgs e) +101  
  20.    Microsoft.SharePoint.WebControls.LayoutsPageBase.OnLoad(EventArgs e) +49  
  21.    System.Web.UI.Control.LoadRecursive() +66  
  22.    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428  

based on this code, method settemplatelibraryfolders() is not implemented.

my aspx application page is

  1. <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>  
  2. <%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>  
  3. <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>  
  4. <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>  
  5. <%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>  
  6. <%@ Register TagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"%>  
  7. <%@ Import Namespace="Microsoft.SharePoint" %>  
  8. <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>  
  9. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TemplateSelector.aspx.cs" Inherits="NOVODUGME.Layouts.NOVODUGME.TemplateSelector" DynamicMasterPageFile="~masterurl/default.master" %>  
  10.   
  11. <asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">  
  12. <script language='javascript' type="text/javascript">  
  13.     // Open template with the corresponding Office app  
  14.     function OpenNewTemplate(strTemplate, strSaveLocation) {  
  15.         var strProgID = "SharePoint.OpenDocuments";  
  16.         createNewDocumentWithProgID(makeAbsUrl(strTemplate),makeAbsUrl(strSaveLocation), strProgID, false);  
  17.         window.frameElement.commitPopup();  
  18.     }  
  19. </script>  
  20.    
  21.   
  22. </asp:Content>  
  23.   
  24. <asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">  
  25.   
  26. <div>  
  27. <div id="Navigation" style="position: absolute; top: 0; left: 0; width: 30em">  
  28.       <asp:TreeView ID="tvFolders" runat="server"></asp:TreeView>  
  29. </div>  
  30. <div id="Content" style="margin-left: 30em;">  
  31.     <asp:ListView ID="lvTemplates" runat="server" GroupItemCount="5" DataKeyNames="Title">  
  32.     <LayoutTemplate>  
  33.        <table cellpadding="5" runat="server" id="tblTemplates">  
  34.              <tr id="groupplaceholder" runat="server"></tr>  
  35.        </table>  
  36.     </LayoutTemplate>  
  37.    <GroupTemplate>  
  38.              <tr id="itemPlaceholderContainer" runat="server" style="height: 80px;">  
  39.                  <td id="itemPlaceholder" runat="server"></td>  
  40.              </tr>  
  41.    </GroupTemplate>  
  42.    <ItemTemplate>  
  43.         <td id="Td1" valign="top" align="center" style="width: 100px;" runat="server">  
  44.            <asp:HyperLink ID="TemplateLink" runat="server" NavigateUrl='<%# Eval("Url") %>' Target="">    
  45.              <asp:Image ID="IconImage" runat="server" ImageUrl='<%# Eval("ImageUrl") %>' />  
  46.                <br />  
  47.   
  48.                 <%# Eval("Title") %>  
  49.             </asp:HyperLink>  
  50.         </td>  
  51.     </ItemTemplate>  
  52.     </asp:ListView>  
  53. </div>  
  54. </div>  
  55.    
  56.   
  57.   
  58. </asp:Content>  
  59.   
  60. <asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">  
  61. Application Page  
  62. </asp:Content>  
  63.   
  64. <asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" >  
  65. My Application Page  
  66. </asp:Content>  
code cs file is
 
  1. using System;  
  2. using Microsoft.SharePoint;  
  3. using Microsoft.SharePoint.WebControls;  
  4. using Microsoft.SharePoint.Administration;  
  5. using System.Collections;  
  6. using System.Data;  
  7. using Microsoft.SharePoint.Utilities;  
  8. using System.Web;  
  9.   
  10.   
  11. namespace NOVODUGME.Layouts.NOVODUGME  
  12. {  
  13.       
  14.     public partial class TemplateSelector : LayoutsPageBase  
  15.     {  
  16.   
  17.         
  18.     
  19. public readonly DataTable _dataTable = new DataTable();  
  20.    
  21.   
  22.      
  23.      
  24.       
  25.         protected void Page_Load(object sender, EventArgs e)  
  26.         {  
  27.   
  28.             if (!IsPostBack)  
  29.                   {  
  30.                       // Instantiate the folder tree if first time on page  
  31.                          SetTemplateLibraryFolders();  
  32.                   }  
  33.                       // Add columns to the datatable  
  34.                             _dataTable.Columns.Add("ImageUrl"typeof(string));  
  35.                             _dataTable.Columns.Add("Title"typeof(string));  
  36.                             _dataTable.Columns.Add("Url"typeof(string));  
  37.                       // if there's no node selected, select the first node,which is the root.  
  38.                          var selectedNode = tvFolders.SelectedNode == null ?tvFolders.Nodes[0].Value :  
  39.                          tvFolders.SelectedNode.Value;  
  40.   
  41.                        GetTemplatesInSelectedFolder(selectedNode);  
  42.   
  43.                              // set the templates as the datasource for the template list view  
  44.                                 lvTemplates.DataSource = _dataTable;  
  45.    
  46.   
  47.           }  
  48.   
  49.         private void SetTemplateLibraryFolders()  
  50.         {  
  51.             throw new NotImplementedException();  
  52.         }  
  53.   
  54.         
  55.          
  56.         private void GetTemplatesInSelectedFolder(string folderUrl)  
  57.         {  
  58.             using (SPSite site = new SPSite("http://test-net.dri.local"))  
  59.                          {  
  60.                        using (SPWeb web = site.OpenWeb())  
  61.                              {  
  62.                                    SPList list = web.Lists.TryGetList("Templates");  
  63.                                    if (list != null)  
  64.                                       {  
  65.                                          SPDocumentLibrary docLib = (SPDocumentLibrary)list;  
  66.                                          SPFolder folder = web.GetFolder(folderUrl);  
  67.                                          AddFilesToDataTable(web, folder);  
  68.                                       }  
  69.                              }  
  70.                         }  
  71.              }  
  72.   
  73.          
  74.          
  75.         private void AddFilesToDataTable(SPWeb docWeb, SPFolder folder)  
  76.            {  
  77.             foreach (SPFile file in folder.Files)  
  78.               {  
  79.                 // get template icon  
  80.                 string docIcon = SPUtility.ConcatUrls("/_layouts/images/",SPUtility.MapToIcon(file.Web, SPUtility.ConcatUrls(file.Web.Url, file.Url),"",IconSize.Size32));  
  81.   
  82.                 // absolute url of the template  
  83.                 string absUrl =(string)file.Item[SPBuiltInFieldId.EncodedAbsUrl];  
  84.                 // click action  
  85.                 string action;  
  86.                 if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["DocLib"]))  
  87.                      {  
  88.                     // get the list from the List query string  
  89.                           Guid? docLibId = new Guid(HttpContext.Current.Request.QueryString["DocLib"]);  
  90.                           SPList selectedLibrary = docWeb.Lists.GetList(docLibId.Value,true);  
  91.                           string docLibUrl = selectedLibrary.DefaultViewUrl;  
  92.                     // remove Forms[%] from the view url to get the  
  93.                     // correct document library url  
  94.                           docLibUrl = docLibUrl.Remove(docLibUrl.LastIndexOf("Forms",StringComparison.Ordinal));  
  95.                 action = string.Format("javascript:OpenNewTemplate('{0}', '{1}');",absUrl,SPContext.Current.Site.RootWeb.Url + docLibUrl);  
  96.                 AddDataToDataTable(docIcon, file.Name, action);  
  97.                 }  
  98.   
  99.                        
  100.                }  
  101.            }  
  102.   
  103.          
  104.               private void AddDataToDataTable(string docIcon,string title,string url)  
  105.                  {  
  106.                      DataRow row = _dataTable.NewRow();  
  107.                      row["ImageUrl"] = docIcon;  
  108.                      row["Title"] = title;  
  109.                      row["Url"] = url;  
  110.                      _dataTable.Rows.Add(row);  
  111.                  }  
  112.    
  113.   
  114.   
  115.   
  116.     }  
  117.      
  118.    
  119.   
  120. }  
where is error? can someone help me with some guide 
 
Answers (4)