I am debugging a SharePoint 2013 solution in Visual Studio and was setting the debugger to the SaveItem method that is overridden. Why does this not get triggered? Following is my code,

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %> 
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SPFormsWPSolnUserControl.ascx.cs" Inherits="FormProject.SPFormsWPSoln.SPFormsWPSolnUserControl" %>

<table runat="server">
            <td><label runat="server" id="labelName">Name:</label></td>
            <td><SharePoint:InputFormTextBox runat="server" ID="inputText1"></SharePoint:InputFormTextBox></td>
            <td> <label runat="server" id="labelAddr">Address:</label></td>
            <td><SharePoint:InputFormTextBox runat="server" ID="InputFormTextBox1" TextMode="MultiLine"></SharePoint:InputFormTextBox></td>
            <td><label runat="server" id="labelState">State:</label></td>
            <td><SharePoint:InputFormTextBox runat="server" ID="InputFormTextBox2"></SharePoint:InputFormTextBox></td>
            <td><label runat="server" id="labelCity">City:</label></td>
            <td><SharePoint:InputFormTextBox runat="server" ID="InputFormTextBox3"></SharePoint:InputFormTextBox></td>
            <td><SharePoint:SaveButton runat="server" ID="draftSave1" ControlMode="New"></SharePoint:SaveButton></td>
            <td><SharePoint:GoBackButton runat="server" ID="cancelButton1" ControlMode="New"></SharePoint:GoBackButton></td>


------------------------------Functionality Part-----------------------------

using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace FormProject.SPFormsWPSoln

    public partial class SPFormsWPSolnUserControl : UserControl
        protected void Page_Load(object sender, EventArgs e)
          //  NewSaveButton gn = new NewSaveButton();
         //   labelTest.InnerText = "";         

    public class NewSaveButton : SaveButton
        protected override bool SaveItem()
            bool success = base.SaveItem();
            SPSite site = SPContext.Current.Site;
            SPWeb web = site.OpenWeb();

            site.AllowUnsafeUpdates = true;
            web.AllowUnsafeUpdates = true;

            SPList list = web.Lists["Customers"];
            SPListItem itemToAdd = list.Items.Add();
            itemToAdd["CustomerID"] = 90;
            itemToAdd["CustomerName"] = "RadioMirchi";
            itemToAdd["CustomerAddress"] = "Vile Parle, Mumbai";
            itemToAdd["CustomerState"] = "Maharashtra";
            itemToAdd["CustomerCountry"] = "India";

            web.AllowUnsafeUpdates = false;
            site.AllowUnsafeUpdates = false;
            return success;


You have created a derived class for SaveButton, but it is not used on the form. And since the new control is never loaded, it will not get hit during debugging.

In your form code "SharePoint:SaveButton" use your NewSaveButton, take a look at this link for hints on how to do this: https://stackoverflow.com/questions/5249295/override-sharepointsavebutton-in-custom-form-template


  • Yeah, thanks for information, but here they are creating and utilizing asp.net server control. What actually I am looking for is that to use SharePoint button control on server side coding and do customization on its PreSaveAction on server side is it possible. – Niranjan Kulkarni Sep 30 '15 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.