ASP.net page without a code behind ASP.net page without a code behind asp.net asp.net

ASP.net page without a code behind


By default Sharepoint does not allow server-side code to be executed in ASPX files. See this for how to resolve that.

However, I would raise that having a code-behind is not necessarily difficult to deploy in Sharepoint (we do it extensively) - just compile your code-behind classes into an assembly and deploy it using a solution.

If still no, you can include all the code you'd normally place in a codebehind like so:

<script language="c#" runat="server">public void Page_Load(object sender, EventArgs e){  //hello, world!}</script>


You can actually have all the code in the aspx page. As explained here.

Sample from here:

<%@ Language=C# %><HTML>   <script runat="server" language="C#">   void MyButton_OnClick(Object sender, EventArgs e)   {      MyLabel.Text = MyTextbox.Text.ToString();   }   </script>   <body>      <form id="MyForm" runat="server">         <asp:textbox id="MyTextbox" text="Hello World" runat="server"></asp:textbox>         <asp:button id="MyButton" text="Echo Input" OnClick="MyButton_OnClick" runat="server"></asp:button>         <asp:label id="MyLabel" runat="server"></asp:label>      </form>   </body></HTML>


yes on your aspx page include a script tag with runat=server

<script language="c#" runat="server">public void Page_Load(object sender, EventArgs e){  // some load code}</script>

You can also use classic ASP Syntax

<% if (this.MyTextBox.Visible) { %><span>Only show when myTextBox is visible</span><% } %>