CodeBehind和Codefile 区别
谢谢.看msdn 我都不懂./天.
CodeFile
指定指向页引用的代码隐藏文件的路径。此属性与 Inherits 属性一起使用可以将代码隐藏源文件与网页相关联。此属性仅对编译的页有效。
CodeBehind
指定包含与页关联的类的已编译文件的名称。该属性不能在运行时使用。
问题是.
真的不懂.请问.2者本质上有什么区别吗?谢谢.希望大家再解释一次.谢谢
CodeFile
指定指向页引用的代码隐藏文件的路径。此属性与 Inherits 属性一起使用可以将代码隐藏源文件与网页相关联。此属性仅对编译的页有效。
CodeBehind
指定包含与页关联的类的已编译文件的名称。该属性不能在运行时使用。
问题是.
真的不懂.请问.2者本质上有什么区别吗?谢谢.希望大家再解释一次.谢谢
...全文
请发表友善的回复…
发表回复
慧解 2012-02-22
- 打赏
- 举报
此帖甚好 学习学习
小琳子 2011-12-26
- 打赏
- 举报
haohao
xty_seven 2011-05-29
- 打赏
- 举报
有点点理解了,谢谢楼上的
lin131 2010-11-17
- 打赏
- 举报
学习了 。。。
heng_200889 2010-09-28
- 打赏
- 举报
[Quote=引用 8 楼 chocolee 的回复:]
CodeFile 与 CodeBehind 的区别
今天同事在把一个Web项目从 Web Site 升级成 Web Application 应用后部署的时候,报错:
Server Error in '/' Application.
------------------------------------------------------------------------------……
[/Quote]
==================
一语中的,我百度了好久终于在此处找到答案了,多谢。
CodeFile 与 CodeBehind 的区别
今天同事在把一个Web项目从 Web Site 升级成 Web Application 应用后部署的时候,报错:
Server Error in '/' Application.
------------------------------------------------------------------------------……
[/Quote]
==================
一语中的,我百度了好久终于在此处找到答案了,多谢。
chenjia2008 2009-03-30
- 打赏
- 举报
CodeBehind一般是.net 1.x里面用的
VS2005网站都是codefile制定后台cs文件,WebApplication是codeehind
以上各位说的很清楚了,编译的区别。
VS2005网站都是codefile制定后台cs文件,WebApplication是codeehind
以上各位说的很清楚了,编译的区别。
andyhooo 2008-02-29
- 打赏
- 举报
自己up./
andyhooo 2008-02-29
- 打赏
- 举报
哈哈
harryheart 2008-02-29
- 打赏
- 举报
mark
conannb 2008-02-29
- 打赏
- 举报
学习
guyan033 2008-02-29
- 打赏
- 举报
Codebehind 是 dll
codefile 是cs
在部署时区分的明显
codefile 是cs
在部署时区分的明显
wxg22526451 2008-02-29
- 打赏
- 举报
学习
LutzMark 2008-02-29
- 打赏
- 举报
up 2
Pig23 2008-02-29
- 打赏
- 举报
飘来学习~~
andyhooo 2008-02-29
- 打赏
- 举报
up
chocolee 2008-02-29
- 打赏
- 举报
CodeFile 与 CodeBehind 的区别
今天同事在把一个Web项目从 Web Site 升级成 Web Application 应用后部署的时候,报错:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: The file '/index.aspx.cs' does not exist.
Source Error:
Line 1: <%@ Page Language="C#" AutoEventWireup="true" CodeFile ="index.aspx.cs" Inherits="Community.IndexHomePage.index" %>
Line 2:
原因就是不知道为啥,采用系统升级工具,没有把这个Web Page 的 CodeFile 变成 CodeBehind 。
而且仅仅只是这一个页面没升级,其他页面都升级了。
再加上这两个属性都是 Code 开头的,一不留神,就会觉得一个属性。结果忙活了一回。
CodeFile 与 CodeBehind 在使用上是有很大区别的
先看 MSDN 上的说明:
CodeBehind
指定包含与页关联的类的已编译文件的名称。该属性不能在运行时使用。
Specifies the name of the compiled file that contains the class associated with the control. This attribute is not used at run time.
CodeFile
指定指向页引用的代码隐藏文件的路径。此属性与 Inherits 属性一起使用可以将代码隐藏源文件与网页相关联。此属性仅对编译的页有效。
Specifies a path to the referenced code-behind file for the control. This attribute is used together with the Inherits attribute to associate a code-behind source file with a user control. The attribute is valid only for compiled controls.
我这里碰到的情况就是,整个Web 项目被编译成了组件,但是 ASPX 页面有如下的定义:
这时候,ASP.net 就需要找 CodeFile 中指定的文件,以便动态编译,但是找不到,所以就报上述错误了。
对于开发时,即 页面的逻辑代码 cs 文件存在的时候,下属两种写法都没有问题。
但是部署到站点后,我们不会部署 cs 文件,这时候,后一种写法就会报找不到文件的错误了。除非你把 cs 也部署出去,否则就会报编译时错误,找不到文件...
今天同事在把一个Web项目从 Web Site 升级成 Web Application 应用后部署的时候,报错:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: The file '/index.aspx.cs' does not exist.
Source Error:
Line 1: <%@ Page Language="C#" AutoEventWireup="true" CodeFile ="index.aspx.cs" Inherits="Community.IndexHomePage.index" %>
Line 2:
原因就是不知道为啥,采用系统升级工具,没有把这个Web Page 的 CodeFile 变成 CodeBehind 。
而且仅仅只是这一个页面没升级,其他页面都升级了。
再加上这两个属性都是 Code 开头的,一不留神,就会觉得一个属性。结果忙活了一回。
CodeFile 与 CodeBehind 在使用上是有很大区别的
先看 MSDN 上的说明:
CodeBehind
指定包含与页关联的类的已编译文件的名称。该属性不能在运行时使用。
Specifies the name of the compiled file that contains the class associated with the control. This attribute is not used at run time.
CodeFile
指定指向页引用的代码隐藏文件的路径。此属性与 Inherits 属性一起使用可以将代码隐藏源文件与网页相关联。此属性仅对编译的页有效。
Specifies a path to the referenced code-behind file for the control. This attribute is used together with the Inherits attribute to associate a code-behind source file with a user control. The attribute is valid only for compiled controls.
我这里碰到的情况就是,整个Web 项目被编译成了组件,但是 ASPX 页面有如下的定义:
<%@ Page CodeFile="***" Inherits="***" %>
这时候,ASP.net 就需要找 CodeFile 中指定的文件,以便动态编译,但是找不到,所以就报上述错误了。
对于开发时,即 页面的逻辑代码 cs 文件存在的时候,下属两种写法都没有问题。
<%@ Page Language="C#" AutoEventWireup="true" Codebehind="index.aspx.cs" Inherits="Community.IndexHomePage.index" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="Community.IndexHomePage.index" %>
但是部署到站点后,我们不会部署 cs 文件,这时候,后一种写法就会报找不到文件的错误了。除非你把 cs 也部署出去,否则就会报编译时错误,找不到文件...
wuyi8808 2008-02-28
- 打赏
- 举报
阿非 2008-02-28
- 打赏
- 举报
阿非 2008-02-28
- 打赏
- 举报
codefile
指定指向页引用的代码隐藏文件的路径。此属性与 Inherits 属性一起使用可以将代码隐藏源文件与网页相关联。此属性仅对编译的页有效。比如VS2005中新建一个网站你会发现编译比WEB应用程序慢很多,但是可以修改代码后不用整体编译刷新页面就可以看到效果.
codebehind
指定包含与页关联的类的已编译文件的名称,编译完后所有cs中的代码打包进dll.该属性不能在运行时使用.提供此属性是为了与以前版本的 ASP.NET 的兼容,以实现代码隐藏功能。在 ASP.NET 2.0 版中,应改用 CodeFile 属性指定该源文件的名称,同时使用 Inherits 属性指定该类的完全限定名称。
指定指向页引用的代码隐藏文件的路径。此属性与 Inherits 属性一起使用可以将代码隐藏源文件与网页相关联。此属性仅对编译的页有效。比如VS2005中新建一个网站你会发现编译比WEB应用程序慢很多,但是可以修改代码后不用整体编译刷新页面就可以看到效果.
codebehind
指定包含与页关联的类的已编译文件的名称,编译完后所有cs中的代码打包进dll.该属性不能在运行时使用.提供此属性是为了与以前版本的 ASP.NET 的兼容,以实现代码隐藏功能。在 ASP.NET 2.0 版中,应改用 CodeFile 属性指定该源文件的名称,同时使用 Inherits 属性指定该类的完全限定名称。
he_8134 2008-02-28
- 打赏
- 举报
一个指向.cs文件 一个指向.dll文件~~~~
也就是"服务启动时编译"与"预编译"的区别吧~~~
也就是"服务启动时编译"与"预编译"的区别吧~~~
加载更多回复(2)