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

梦想与她 提交于 2019-12-12 06:06:41

问题


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:

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?

UPDATE

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

UPDATE 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:

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

回答1:


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

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

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

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.



来源:https://stackoverflow.com/questions/43327349/how-can-i-add-a-code-behind-file-to-an-aspx-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!