I created an Application page within the Central Administration. Then I added some Controls to it (TextBox, Button - all ASP controls). Then I tried to add an event handler for the button click event. After that the page throws an exception - nothing very useful, it just says that it can not find the method:

Here is some sample code:

<asp:Button ID="btnSave" runat="server" Text="Save" OnClick="BtnSave_Click" />

protected void BtnSave_Click(object sender, EventArgs e)
    //do stuff            

What I checked:

  • The namespaces are correct.

  • The *.aspx file Inherits from the correct class.

  • The Page_Load method is executed fine. The debugger goes in there and the code in it works fine. So the code behind file is not missing.

  • There is no problem with the name of the method. I copied it.

  • The designer file is generated ok.

Any ideas?

Edit 1:

Here is the entire code, for now it does nothing but still fails:

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ 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" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ReminderTimerConfigurationPage.aspx.cs" Inherits="SomePath.ReminderTimerConfigurationPage" DynamicMasterPageFile="~masterurl/default.master" %>

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">


<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:Button ID="Button1"
        runat="server" Text="Button" />

<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
Application Page

<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" >
My Application Page

And the CodeBehind:

using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace SomePath
    public partial class ReminderTimerConfigurationPage : LayoutsPageBase
        protected void Page_Load(object sender, EventArgs e)
            Button1.Click += BtnSave_Click;

        protected void BtnSave_Click(object sender, EventArgs e)
            string newXml = TextBox1.Text;

In the button click event handler the TextBox1 is null.

Another problem is that when I try to rename any of the controls it blows up completely: Object reference not set to instance of an object.

  • Just a method to troubleshoot.. Copy the existing code of BtnSave_Click , remove OnClick="BtnSave_Click" from aspx page and add btnSave.Click+=BtnSave_Click; page_load in code behind.Press tab twice so that VS generates the eventhandler method.Paste the code into that method and try running.
    – Unnie
    Mar 27, 2014 at 6:54
  • Ok it no longer throws the exception and it enters the method but when I try to work with any of the controls on the page they are all null.
    – Gesh
    Mar 27, 2014 at 7:06
  • Can you post the code over here and explain what the code does .It will be helpful
    – Unnie
    Mar 27, 2014 at 7:14

1 Answer 1



I was using CKSDev to deploy my code, the problem was there. I tried the Visual Studio deploy, did an iisreset and it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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