我有一个自包含的aspx脚本,现在需要一个小类来实现一个功能.有没有办法在不添加代码隐藏(aspx.cs)文件的情况下在此页面的代码中声明一个类?
为了整洁,我想将所有内容保存在一个文件中.
I'd like to keep everything in one single file for neatness sake.我没有看到混合代码和标记如何整洁.话虽这么说,你可以在一个<script>块内添加类,例如: -
<script runat="server">
public class MyClass
{
public static string Example()
{
Response.Write("Hello world");
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3423 次 |
| 最近记录: |