SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i am developing one sandbox solution. i have one .aspx page in my solution, there i need to create one button and need to write server-side event for that button. But i couldn't do it. getting error as "The event handler 'OnClick' is not allowed in this page."

<%@ Page Language="C#" %>
<html dir="ltr" xmlns="">`



        <form id="form1" runat="server">

            <asp:Button ID="btnClick" Text="Click Me" runat="server"
             OnClick="Btn_Click" /> 


Can't we add server-side event for controls in sandbox solution.?

share|improve this question

You can't use Application Pages in Sandboxed Solutions. See this link from Microsoft regarding what components are allowed in Sandboxed Solutions.

An alternative to what you are doing, would be to create a Web Part. If you create and deploy a custom Web Part, you can deploy code, create buttons etc. Make sure not to create a Visual Web Part, though, as these are not supported.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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