什么是.aspx文件中的code隐藏文件丢失时,preferred解决方法吗? [英] What is the preferred workaround when an .aspx file's code-behind file is missing?

查看:136
本文介绍了什么是.aspx文件中的code隐藏文件丢失时,preferred解决方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在源$ C ​​$ C的VB ASP.NET网站,我试图让编译,我有一对夫妇的文件'bla.aspx.vb'不存在的错误;有相应的.aspx文件,但它缺少它的同伴.aspx.vb code隐藏文件。

In the source code for a VB ASP.NET website that I'm trying to get compiling, I've got a couple of "The file 'bla.aspx.vb' does not exist" errors; there is a corresponding .aspx file, but it's missing its companion .aspx.vb code-behind file.

错误味精显示,因为这在.aspx文件:

The error msg displays because of this in the .aspx file:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Bla.aspx.vb" Inherits="cms_ShowEscalatorRule" %>

要刚刚获得该项目编译(这仅仅是在本地运行的项目中,code更改不会影响生产code),这将是preferable为:

To just get the project compiling (this is just for running the project locally, the code I change won't affect the production code), would it be preferable to:

0) Comment out that section entirely
1) Remove the "CodeFile="Bla.aspx.vb" portion
2) Add a code-behind file 

如果最后的选择是最好的,什么需要在它code极少量的 - 刚好够prevent了丢失的文件的错误

If the last option is best, what needs to be in it for a minimal amount of code - just enough to prevent the "missing file" error?

这是相当可怕的,我认为有对.aspx文件没有上下文菜单项,它允许创建一个最小的相应.aspx.vb。

It's rather macabre to me that there is no contextual menu item for .aspx files that allows a minimal corresponding .aspx.vb to be created.

推荐答案

您可以的有无的有一个文件,因为在.aspx可能有引用(你将不得不重新创建那些在code-后面)从code-隐藏文件的项目。

You may have to have a file because the .aspx may have references (and you will have to recreate those in the code-behind) to items from the code-behind file.

这是所需的最低是一类从页面继承:

The minimum that's needed is a class inheriting from Page:

public class Bla : System.Web.UI.Page
{ 
}

本 - 当然 - 不是强制性的 - 你不妨用另一种方法,并在.aspx文件中的服务器端脚本块内联C-背后的$ C $。然而,前一种方法是更整洁。

This - of course - is not mandatory - you may as well use the alternative approach and inline the code-behind in a server-side script block in the .aspx file. Former approach however is much neater.

这篇关于什么是.aspx文件中的code隐藏文件丢失时,preferred解决方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆