简体   繁体   English

Visual Studio创建的WebForms与空白文件

[英]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.

相关问题 Visual Studio创建空白的aspx:1文件 - Visual Studio creating blank aspx:1 files WebForms中的Visual Studio参考混合 - Visual Studio reference mixup in WebForms Visual Studio 2022 C# ASP.NET 在服务器上找不到带有服务引用文本文件的 Web 表单(HTTP 错误 404.0) - Visual Studio 2022 C# ASP.NET Webforms with service reference text files not found on server (HTTP Error 404.0) 如何在Visual Studio 2013 Webforms项目中引用cordova.js? - How to reference cordova.js in Visual Studio 2013 webforms project? ASP.NET WebForms Visual Studio中的连接字符串LocalDB - Connection strings LocalDB in ASP.NET WebForms Visual Studio Visual Studio 2019 右键单击​​转到 WebForms 缺少的定义 - Visual Studio 2019 Right-click Go To Definition missing for WebForms WebForms 的智能感知在 Visual Studio 2019 中不起作用 - Intellisense for WebForms doesn't work in Visual Studio 2019 在设计模式下自定义Visual Studio intelliSense(webforms aspx) - customize visual studio intelliSense while in design mode (webforms aspx) 可以在 Visual Studio 2013 中开发的 Asp.net 4.5.1 中的 WebForms 应用程序在 Visual Studio 2019 中打开和工作吗? - Can a WebForms application in Asp.net 4.5.1 developed in Visual Studio 2013 be opened and worked on in Visual Studio 2019? Visual Studio 打开空白浏览器页面 - Visual Studio Opens Blank Browser Page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM