Saturday, March 31, 2012

Set breakpoint in <script> in aspx source

How might I set a breakpoint in <script> (JS) in aspx source? I have no trouble if it's an external JS, but VS2005 Std sez "not a valid location for a breakpoint" if I try to set one in a <script> that's imbedded in the aspx file.

It′s really easy my friend:

1. Set the breakpoint (while not debugging the aspnet code).

2. While running your web page try to connect to the IExplore.exe process from the Debug menu, and that′s all.

Hope this helps.


Thanks for the input. Hmm...

here's the line I'd like to break at:

<script>
ScrollSelectedIDIntoView()
</script>

it's sitting at the bottom of a content panel of a "child" page. The function "ScrollSelectedIDIntoView" is in a JS file that's loaded into the Master page. (I moved the JS out to solve the problem, but this should still work). The code works fine.

However, when I click in the left margin next to the ScrollSelectedIDIntoView() line, to set the breakpoint, with code in "not debugging" mode, I get the message "this is not a valid location for a breakpoint" in the bottom bar of VS2005.


You were right, I was using my VS 2003 and it worked in there, but it happens just the same as you described (not a valid location for a breakpoint), that′s because it changed a little inVS 2005 and here is how it works:

1. Make sure you have the Internet explorer script debugging option enabled.

2. Start your project in debug mode and go to the debug-> Windows-> Script Explorer and browse the running scripts from there.

More info on these 2 good articles:

http://geekswithblogs.net/lazydeveloper/archive/2006/07/10/84552.aspx

http://timstall.dotnetdevelopersjournal.com/debugging_javascript_in_visual_studio.htm

Hope this helps!


Nikhil'sWeb Development Helper is great tool in web development and debugging. It makes you debug your script on the fly and its integrated with your IE

Thanks


Whoa, looks like I haven't been back in a while. Thanks for the inputs!

0 comments:

Post a Comment