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="http://www.w3.org/1999/xhtml">`



        <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.?

1 Answer 1


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.

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.