3

I have an ASPX page with no code behind (that is, no .aspx.cs with the same name). In the code is this line:

<div style="overflow: hidden; text-align: center; z-index: 105;">
    <%= MainNavBarHTML %><%= SubNavBarHTML %>
</div>

I've searched the rest of the program for MainNavBarHTML and SubNavBarHTMl, but can't find any reference to them. How do I find what fills those elements?

Yuck
  • 49,664
  • 13
  • 105
  • 135
boilers222
  • 1,901
  • 7
  • 33
  • 71
  • 3
    What does the page header look like? Basically, what does the `CodeFile` directive reference? – Yuck Nov 16 '12 at 15:13
  • Have you tried right-clicking on it and selecting "Go to definition" ? This should take you to the method - or the object browser if it's part of a library – Darren Wainwright Nov 16 '12 at 15:17
  • Look at the codebehind file for a `protected/public` variable with that name. – Tim Schmelter Nov 16 '12 at 15:18
  • @TimSchmelter OP has stated that there isn't a code behind file available. – Yuck Nov 16 '12 at 15:19
  • Is anything displayed? Maybe the variables don't exist. – Steve Wellens Nov 16 '12 at 15:20
  • There is no codebehind file. Something is being displayed in them. They're in a .aspx file that is used as the header for another page and the header displays fine. I just don't know what controls what is seen in the header. – boilers222 Nov 16 '12 at 20:44

4 Answers4

5

You might want to check out the CodeFile vs CodeBehind question.

If your ASPX markup has the CodeFile directive, it will look for the associated .cs file:

<%@ Page
    Language="C#"
    CodeFile="CustomerDetail.aspx.cs"
    Inherits="SomePage" %>

If, instead, it has the CodeBehind directive listed it will look in the Bin folder for an assembly that has the class defined:

<%@ Page
    Language="C#"
    CodeBehind="CustomerDetail.aspx.cs"
    Inherits="SomePage" %>

The naming of these two directives is beyond unfortunate. If the application is using CodeBehind (which it sounds like it is) you may not have access to the source and will be unable to view the definition for those properties, short of using a .NET reflection tool against the compiled assemblies.

Community
  • 1
  • 1
Yuck
  • 49,664
  • 13
  • 105
  • 135
  • @boilers222 Please post the page directive section in its entirety then. – Yuck Nov 16 '12 at 21:13
  • 1
    @boilers222 The page directive is only the section I've listed above. If even that's too much to share then unfortunately I can't offer much more assistance. – Yuck Nov 19 '12 at 22:16
2

In Visual Studio, Put your cursor on the text and press F12 to jump to definition or right-click on the text and choose "Go to definition".

avb
  • 1,558
  • 1
  • 14
  • 37
0

Adding this as an answer now (rather than in the comments).

Your project will have the code somewhere, though it may be part of another library (DLL).

If you right-click on the property (in this case either MainNavBarHTML or SubNavBarHTML, and from the context-menu select "Go to definition" VS will show you either the code (if it's in a *.cs page) or load the object browser and navigate to that property, allowing you to see exactly where the property is located.

Depending on your VS settings F12 may do nothing - does nothing on mine for example. Right-clicking and choosing "Go to definition" is the most stable way to navigate - in my opinion.

Darren Wainwright
  • 30,247
  • 21
  • 76
  • 127
-2

Boiler, the code is still there, you just have to select the file and hit F7 and you will see the code...

Mr_Green
  • 40,727
  • 45
  • 159
  • 271
Nathan
  • 24,586
  • 4
  • 27
  • 36
  • what he is suggesting effectively takes the user to the code behind for that page. The OP doesn't have one. He needs to right-click on the code and "Go to definition". either that or i have mistaken the F7 shortcut for something other than 'View Code' – Darren Wainwright Nov 16 '12 at 15:42