在visual studio中,如何在javascript文件中的每个函数上添加断点?

时间:2023-01-16 16:43:08

In * here and here I found ways to add breakpoint in every method of a class. But I can't find a way to add a break point to every method of a jquery/javascript file.

在这里和这里的*中,我找到了在类的每个方法中添加断点的方法。但我找不到一种方法来为jquery / javascript文件的每个方法添加一个断点。

This is exactly what I am trying to achieve. When I click on a checkbox in a custom control gridview (asp.net) , the entire row gets highlighted. When viewing the generated HTML, the row is nested under many other elements with their own ids and classes. There is some jquery code possibly within this 500kb jquery file, that subscribes to some event of one of the tags, either based on id or class. If I find a way to add a breakpoint to every method, I can pin point which method is responsible for highlighting the row.

这正是我想要实现的目标。当我单击自定义控件gridview(asp.net)中的复选框时,整个行都会突出显示。查看生成的HTML时,该行嵌套在具有自己的ID和类的许多其他元素下。这个500kb的jquery文件中可能有一些jquery代码,它们可以根据id或class来订阅其中一个标签的某个事件。如果我找到一种方法为每个方法添加一个断点,我可以指出哪个方法负责突出显示该行。

(What I have gathered by looking at the generated HTML is that, a jquery function assigns a css class to the selected row)

(通过查看生成的HTML收集的是,jquery函数将css类分配给选定的行)

1 个解决方案

#1


1  

Here is a link for how to debug javascript within Visual Studio:

这是一个如何在Visual Studio中调试javascript的链接:

http://weblogs.asp.net/scottgu/archive/2007/07/19/vs-2008-javascript-debugging.aspx

http://weblogs.asp.net/scottgu/archive/2007/07/19/vs-2008-javascript-debugging.aspx

However, setting a break-point on every single method and waiting for one of them to hit is not the correct way to do debugging. You should focus on the events which are fired after the row is selected. You can do this by looking at the javascript which was written to interact with the gridview.

但是,在每个方法上设置断点并等待其中一个方法命中并不是正确的调试方法。您应该关注选择行后触发的事件。您可以通过查看为与gridview交互而编写的javascript来执行此操作。

One place to start would be to look at the solution in IE, open up the developer tools by pressing F12. Using those tools will get you where you want to be.

一个开始的地方是查看IE中的解决方案,按F12打开开发人员工具。使用这些工具可以帮助您实现目标。

P.S. Developer tools in IE also allow you to do javascript debugging right there in the browser.

附: IE中的开发人员工具还允许您在浏览器中进行javascript调试。

#1


1  

Here is a link for how to debug javascript within Visual Studio:

这是一个如何在Visual Studio中调试javascript的链接:

http://weblogs.asp.net/scottgu/archive/2007/07/19/vs-2008-javascript-debugging.aspx

http://weblogs.asp.net/scottgu/archive/2007/07/19/vs-2008-javascript-debugging.aspx

However, setting a break-point on every single method and waiting for one of them to hit is not the correct way to do debugging. You should focus on the events which are fired after the row is selected. You can do this by looking at the javascript which was written to interact with the gridview.

但是,在每个方法上设置断点并等待其中一个方法命中并不是正确的调试方法。您应该关注选择行后触发的事件。您可以通过查看为与gridview交互而编写的javascript来执行此操作。

One place to start would be to look at the solution in IE, open up the developer tools by pressing F12. Using those tools will get you where you want to be.

一个开始的地方是查看IE中的解决方案,按F12打开开发人员工具。使用这些工具可以帮助您实现目标。

P.S. Developer tools in IE also allow you to do javascript debugging right there in the browser.

附: IE中的开发人员工具还允许您在浏览器中进行javascript调试。