如何将代码隐藏文件添加到aspx页面? [英] How can I add a code-behind file to an aspx page?

查看:121
本文介绍了如何将代码隐藏文件添加到aspx页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在遗留应用程序中有两个页面需要添加功能.

There are two pages in a legacy app to which I'm addding fuctionality.

其中一个.aspx文件显示设计"视图时,在属性"窗格中显示事件"选项卡:

One of the .aspx files, when the "Design" view is shown, sports an Events tab in the Properties pane:

但是,另一个则没有-它仅显示属性:

The other, though, does not - it only shows Properties:

我需要在此代码中添加一个自定义方法;如何创建相应的.vb代码隐藏文件,可以在其中添加此方法?

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?

我尝试了jackjop的建议,但是F7却什么也没做,而且我似乎没有显示所有文件"字形:

I tried jackjop's suggestions, but F7 did nothing, and I do not seem to have the "Show All Files" glyph:

我尝试将其添加到.aspx文件的顶部,以镜像aspx/aspx.vb对中的内容,这些对可以按我的意愿进行工作,但似乎没有什么区别:

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:

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

推荐答案

创建ASPX文件时,它还会创建一个代码隐藏文件.您只是看不到它.

When you create an ASPX file it also creates a code-behind file. You just can't see it.

从aspx文件中,按F7或在解决方案资源管理器中单击Show All Files按钮.

From aspx file press F7 or click Show All Files button in Solution Explorer.

请注意,当未单击Show All Files时,它不会在文件后面显示代码.

Notice that when Show All Files is not clicked, it doesn't show code behind files.

或者您也可以直接在Solution Explorer上的aspx文件上单击鼠标右键,然后单击View Code.如果这还是行不通的,那么您可能删除了文件后面的代码,建议您重新创建每个文件.

Or you can just simply right-click on aspx file on Solution Explorer and click View Code. If this also does not work, then you probably deleted the code behind files, I suggest you re-creating every file.

这篇关于如何将代码隐藏文件添加到aspx页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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