Search code examples
asp.netvb.netaspx-user-control

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:

enter image description here

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

enter image description here

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:

enter image description here

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" %>

Solution

  • 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.

    enter image description here

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

    enter image description here

    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.