以上web应用程序除了对webform1.aspx有改动,其他文件全部是由他自己生成的!哪位大哥讲得好可以再加分!
解决方案 »
- 【急】asp.net导出Excel,在本机测试OK,发布后无法导出。附源码,在线等!
- css问题。。。。有些css代码看不懂。。
- Page.RegisterStartupScript的简单问题
- 由Matrix程序建立的DataGrid表的分页,选择,编辑,删除,怎样用啊?
- 有请POP3高手
- 招聘asp.net程序员
- .NET的WEB CONTROL控件只能在IE5.5以上才能正常使用,有没有其他能在IE5上使用的替代控件?
- 关于用户控件的问题,请教:)
- 在Page_Load中怎么取得是那个控件的事件被激发
- asp.net异常,求大神!!!
- 各路高手:怎么用ASP.NET做出类似JAVASCRIPT的联动选择的下拉框
- 有关ADO.NET的错误问题!请指教!
<%@ Application Codebehind="Global.asax.cs" Inherits="WebApplication1.Global" %>
<%@ Application Codebehind="Global.asax.cs" Inherits="WebApplication1.Global" src ="Global.asax.cs"
%>
在webform1.aspx中的第一行
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication1.WebForm1" %>
改成
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication1.WebForm1" src ="WebForm1.aspx.cs" %>
原因是使用VS时,代码和网页是分开存放的,不象完全手工时可以放在一个文件里.
ASP.NET只能自动编译ASPX网页文件,而不会自动编译代码文件.
文件WebForm1.aspx中的
Inherits="WebApplication1.WebForm1" 表示是命名空间WebApplication1中的WebForm1类
文件Global.asax中的
Inherits="WebApplication1.Global"类似。只有在编译以后才会有类WebForm1和Global。
可以在bin目录里面看到dll。
就像java里面在jsp中使用javabean前要将javabean编译为字节码一样,现在也要将cs编译为中间码。
----------------------------------------------------------
<%@ language=c# inherits="Example1" src="myexample1.cs" %>
<html>
<head>
<title>
My Example
</title>
</head>
<body>
<form runat=server>
<asp:button id=btn1 text="Click Me" OnClick="btn_Click" runat=server />
<asp:label id=lbl runat=server />
</form>
</body>
</html>myexample1.cs
--------------------------------------------------------------------------
using System;
using System.Web.UI;
using System.Web.UI.WebControls;public class Example1 : System.Web.UI.Page
{
public Button btn;
public Label lbl;
public void btn_Click(object sender , EventArgs e)
{
lbl.Text="The Button Is Clicked";
}
}以上两文件是在记事本中编辑。望赐教!
首先,比较一下你测试时候的文件和用vs.net输出的文件可以发现。
1:你的Global.asax中没有Inherits="WebApplication1.Global"(可能没有Global.asax)
2:你用的是inherits="Example1" src="myexample1.cs";而用vs.net输出的文件是Inherits="WebApplication1.WebForm1"。它表明要到一个命名空间去找,你的是在相同目录中找。在aspx编译时,你现在这种情况可以获得需要的文件它也就编译通过了。