简体   繁体   English

如何将代码隐藏文件添加到aspx页面?

[英]How can I add a code-behind file to an aspx page?

There are two pages in a legacy app to which I'm addding fuctionality. 在遗留应用程序中有两个页面需要添加功能。

One of the .aspx files, when the "Design" view is shown, sports an Events tab in the Properties pane: 显示“设计”视图时,.aspx文件之一显示“属性”窗格中的“事件”选项卡:

在此处输入图片说明

The other, though, does not - it only shows Properties: 但是,另一个则没有-它仅显示属性:

在此处输入图片说明

I need to add a custom method to this code; 我需要在此代码中添加自定义方法; how can I create a corresponding .vb code-behind file where I can add this method? 如何创建相应的.vb代码隐藏文件,可以在其中添加此方法?

UPDATE 更新

I tried jackjop's suggestions, but F7 did nothing, and I do not seem to have the "Show All Files" glyph: 我尝试了jackjop的建议,但是F7没有执行任何操作,而且我似乎没有“显示所有文件”字形:

在此处输入图片说明

UPDATE 2 更新2

I tried adding this to the top of the .aspx file, mirroring what is in the aspx/aspx.vb pair that works as I want, but it didn't seem to make any difference: 我尝试将其添加到.aspx文件的顶部,以镜像按要求工作的aspx / aspx.vb对中的内容,但似乎没有任何区别:

<%@ Page Language="VB" AutoEventWireup="true" CodeFile="custmaint_entry.aspx.vb" Inherits="pages_custmaint_entry" %>

When you create an ASPX file it also creates a code-behind file. 创建ASPX文件时,它还会创建一个代码隐藏文件。 You just can't see it. 您只是看不到它。

From aspx file press F7 or click Show All Files button in Solution Explorer. 在aspx文件中,按F7键或在“解决方案资源管理器”中单击“ Show All Files按钮。

在此处输入图片说明

Notice that when Show All Files is not clicked, it doesn't show code behind files. 请注意,当未单击“ Show All Files时,它不会在文件后面显示代码。

在此处输入图片说明

Or you can just simply right-click on aspx file on Solution Explorer and click View Code . 或者,您只需在Solution Explorer上右键单击aspx文件,然后单击View Code If this also does not work, then you probably deleted the code behind files, I suggest you re-creating every file. 如果这还是行不通的,那么您可能删除了文件后面的代码,建议您重新创建每个文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM