Using breakpoints to debug Javascript in IE and VS2008

14,623

Solution 1

try typing "debugger" in the source where you want to break

Solution 2

Make sure you are attached to the correct process. For example, once you have your page loaded in IE,

  1. Switch to Visual Studio and go to the Debug menu.
  2. Choose "Attach to Process"
  3. Find iexplore in the list and select it.
  4. Click the "Select..." button.
  5. In the dialog, choose "Debug these code types:" and select only "Script".
  6. Click "OK"
  7. Click "Attach"

See if that helps get you debugging javascript.

Solution 3

this happened to me also. The breakpoints stopped to work in some functions. In my case, the problem was that I used <%=..%> inside the script. As far as I could figure out reading MSDN, this happens because Visual Studio maps the breakpoint lines from the .ASPX to the resulting HTML based on line content, so when you put a <%=..> your resulting script will be different from the one in the .ASPX file.

Solution 4

You shouldn't have to put debugger in the javascript. I had this happen and the reason was there was an error in the script in a try catch block in terms of syntax. As soon as I fixed the syntax, breakpoints mapped correctly again.

Share:
14,623
Brad8118
Author by

Brad8118

I graduated from RIT (Rochester Institute of Technology) in 2006 with a computer science degree. While at RIT I played for the Men's Varsity Soccer Team. I'm currently working for InfoDirections, which is located in Rochester NY. I've only been working here for about a month now and it seems to be a very friendly and enjoyable place to work. The company strives to be developed around its employees. No one is pulling out their hair and the company has lots of events to keep moral high. Info Dirs develops software for telecommunications billing solutions. I'm learning what this really means everyday. The create a software portal when one can logon and check their landline/mobile bill, add new features, pay online and more. We also create the app that creates each user profile, the phone plan, calculate the taxes, manage how to bill when out of network and much much more.

Updated on June 04, 2022

Comments

  • Brad8118
    Brad8118 about 2 years

    I am not able to use the breakpoint in Studio with Javascript. I'm able to debug if I use the debugger;

    I've seen this Breakpoint not hooked up when debugging in VS.Net 2005 question already. I tried the answer and it didn't work.

    Looking in the Modules window, V.Mvc.Jobtrakt.PDB is loaded properly, but it points to a temp folder C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\dbc0c0c5\f64a99b3\assembly\dl3\9de055b3\eb1303b1_9760c901\V.Mvc.Jobtrak.pdb: Symbols loaded.

    I would have thought that it would point to: \JobTrak\Website\V.Mvc.Jobtrak\V.Mvc.Jobtrak\obj\Debug ( this is within the project directory)

    But regardless of the location I closed VS 2008 and then blew away the temp folder (listed above), the bin and obj folders.

    Opened VS 2008 and did a clean. I set a break point in the js and it seemed like it would work now ( The breakpoint was filled in) Started to debug and it never breaks on the breakpoint. Look at the break point and it now is a red circle with a red dot and a warning indicator. Hovering over the breakpoint gives me this useful information: The breakpoint will not currently be hit. The location could not be mapped to a client side script. See help for ASPX Breakpoint mapping. I am not being redirected, the breakpoint is with in a function. blah blah blah this should be working.

    So I was wondering if anyone has any ideas? Is anyone able to set breakpoints in VS2008 and have them work?

  • palehorse
    palehorse over 15 years
    Good call Greg. That one is a definite fast track to the debugger.
  • Brad8118
    Brad8118 over 15 years
    This does work. I was trying to get the breakpoints to work.
  • random_user_name
    random_user_name almost 12 years
    Your two lines are identical? What is the difference supposed to be?
  • Brad8118
    Brad8118 over 9 years
    Yikes, Only 6 years later to accept. Apparently this still works :)
  • mastov
    mastov almost 9 years
    What is all this code? Does this have anything to do with the question?