[英]Visual Studio creation of WebForms vs Blank Files
When trying to write the codebehind file for its associates aspx page a colleague and I were stumped as to why the Controls within file.aspx were not appearing in the codecompletion, nor were they compiling without error. 当试图为其同事aspx页面编写代码隐藏文件时,一位同事和我很困惑为什么file.aspx中的控件没有出现在代码完成中,或者它们也没有错误地编译。
When i created the file.aspx and file.aspx.cs I had created these items as blank files, the file.aspx.cs build action was set to Compile while the file.aspx Build Action was Content. 当我创建file.aspx和file.aspx.cs并将这些项目创建为空白文件时,file.aspx.cs生成操作设置为Compile,而file.aspx Build Action设置为Content。
We created a new "webform" item that automatically generated the SecondFile.aspx and the SecondFile.aspx.cs file and associated them. 我们创建了一个新的“ webform”项,该项会自动生成SecondFile.aspx和SecondFile.aspx.cs文件并将它们关联。 We copied the HTML and code from file to SecondFile and the code completion worked, and the codeBehind compiled correctly. 我们将HTML和代码从文件复制到SecondFile,并且代码完成工作正常,并且codeBehind正确编译。
Why? 为什么?
您没有提供足够的信息,但是我认为您可能忘记了将页面声明放在.aspx文件的顶部
<%@ Page Language="C#" CodeFile="file.aspx.cs" Inherits="my_ascx_class_name" %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.