没有code后面ASP.net页 [英] ASP.net page without a code behind
问题描述
我有一个ASP.Net页与C#code的后面。
I have an ASP.Net page with a C# code behind.
不过,我一直在问,不使用后面的code - 这样它会更容易在SharePoint部署。
However, I've been asked to not use a code behind - so that it will be easier to deploy in SharePoint.
有没有一种方法,包括在ASP.Net页的C#code,无需使用单独的code隐藏文件?
Is there a way to include the C# code in the ASP.Net page, without using a separate code behind file?
推荐答案
这是默认的SharePoint不允许在ASPX文件执行服务器端code。 <一href=\"http://mysharepointblog.com/post/2008/01/Running-$c$c-Blocks-In-Your-SharePoint-ASPX-Pages.aspx\">See这了解如何解决这个问题。
By default Sharepoint does not allow server-side code to be executed in ASPX files. See this for how to resolve that.
不过,我会提高,有一个code-背后不一定难在SharePoint中部署(我们做广泛的) - 只要编译code-隐藏类为一个程序集,并使用部署解决方案。
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.
如果还没有,你可以包括所有code你通常在codebehind像这样的地方:
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>
这篇关于没有code后面ASP.net页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!