Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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">`

    <head>
    </head>

    <body>

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

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

        </form>
    </body>
</html>

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

share|improve this question
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.