Don*_*mmy 23 asp.net mono app-code code-behind
我在"App_Code"文件夹中的文件中有一个类.我可以在"aspx"文件中使用它,但不能从代码隐藏文件中使用它.如何让代码隐藏可见?
注意:这是Mono上的ASP.Net,我直接编写类,而不是使用IDE来编译它们
我的文件:
<%@ Page language="c#" src="TestAppCode.aspx.cs" Inherits="TestAppCode.TestAppCode" AutoEventWireup="true" %>
<html>
<head>
<title>Test App_Code Folder</title>
</head>
<body>
<form id="contactForm" runat="server">
<asp:TextBox id="Name" runat="server" ></asp:TextBox>
<asp:TextBox id="Age" runat="server" ></asp:TextBox>
<asp:Button ID="Submit" runat="server" Text="Submit" onclick="SubmitForm" />
</form>
</body>
<html>
Run Code Online (Sandbox Code Playgroud)
using System;
using System.Web.UI.WebControls;
namespace TestAppCode
{
public class TestAppCode : System.Web.UI.Page
{
protected void SubmitForm(object sender, EventArgs e)
{
//It fails here with the error: CS0246: The type or namespace name
//`MyAppCodeClass' could not be found. Are you missing a using
//directive or an assembly reference?
MyAppCodeClass m = new MyAppCodeClass();
}
}
}
Run Code Online (Sandbox Code Playgroud)
public class MyAppCodeClass
{
public MyAppCodeClass() {}
}
Run Code Online (Sandbox Code Playgroud)
我尝试给它一个名称空间,但这并不能解决问题.
| 归档时间: |
|
| 查看次数: |
31153 次 |
| 最近记录: |