How to debug Script 1 in vs.net

Source: Internet
Author: User

How to debug scripts in vs.net
1. Remove the "Disable script debugging option" of IE.
2. In vs.net, set an HTML file as the startup page and set a breakpoint on the file. Remember: Set the HTML file as the startup page
If yourProgramIs ASP, or aspx, there is also such a method:
1.
A) Add alert () where you want to stop (),
B) then run the webpage,
C) use attach to process (vs.net and vs InterDev both have this menu item) to connect to your process,
D) do not click "OK" after the alert () (set above) statement ",
E) return to debugger (vs.net or InterDev) to pause the process,
F) Click "OK" in the warning window ",
G) then the script stays at Alert (next of the statement)
2. Use the "debug" menu under the browser to stop the next statement "function, you can also debug the script well

Typical Javascript script debugging skills
When debugging a Javascript script, if an error occurs, the IE status bar will contain a question mark [click this question mark], or an error box will pop up. In order to locate the error as soon as possible, the following are common debugging methods:
1. If the object is null or the object cannot be found, the ID, name, or DOM statement is incorrect. Check the row where the error is located;
2. if the error is located on a function call, it indicates that the function body has a problem. Go to the function body to find the cause.
3. to speed up, you can use/**/comment out a part of it first.Code, And check gradually;
4. You can add alert (XXX) to check whether the variable has obtained the expected value;
5. The error reports of IE are often inaccurate. For example, if line 18 is incorrect, there are sometimes 19 rows with errors;
6. In order to ensure that the code can run correctly, use the try {} catch {} statement to make sure the code is not correct.

When beginners do not pay attention to the Case sensitivity, such as the innerhtml attribute, they are easy to write as innerhtml. Generally, if an object does not support this attribute or method prompt, It is case-sensitive. There is another possibility, that is, you are trying to use an attribute or method that is not at all.

1. Question Mark [click this question mark], or an error box pops up to locate the error as soon as possible
Click the question mark to check whether there is an error in line n + 1. Move forward without any
What is important is experience and self-written code.
2. The program code should be standardized, and brackets should be matched. Use the tab key whenever possible.

The error of missing; number is not a few; number, but does not contain valid operators in your expression, such as STR = "sdfsdsdf" + "dfsdfsd
And so on.

Without syntax errors
I often use alert (); return; to gradually determine the error range; when debugging JSP programs, It is out. println ("Run here right! "); Out. Close ()

I directly write an Assert function, throw (MSG) where possible, and then use the debugger to view it.
Do not mention the wrong id. Most often, a function returns NULL. In my opinion, I should not return null.
VaR OBJ = somefunction ();
Assert (null! = OBJ, "Var OBJ = somefunction (); return null ");
Function assert (mustbetrue, MSG)
{
If (mustbetrue = false) Throw (New error (-1, "assert: \ n" + MSG ));
}
Function assert (mustbetrue, MSG)
{
If (mustbetrue = false) Throw (New error (-1, "assert: \ n" + MSG ));
}
Vs. NET is the best script debugger.
Monitor everything ..

Use Visual InterDev to debug

A little bit about catch, from the department training example
<SCRIPT>
Try {
X = y; // cause an error.
}
Catch (e) {// create local variable E.
Alert (E); // prints "[object Error]".
Alert (E. Number & 0 xFFFF); // prints 5009.
Alert (E. Description); // prints "'y' is undefined ".
}
</SCRIPT>

Http://groups.google.com/groups? Q = debugging + JavaScript & Ie = utf8 & OE = utf8 & HL = en

Debug JavaScript with vs.net
1. First, you need to allow your IE to debug the script. The specific steps are as follows:
Choose IE> tool menu> inter option> Advanced Tab> disable script debugging.
2. Open vs.net and create a new Asp.net project (or open a project)
3. Run the page you want to debug
4. When your page is displayed in IE, return to vs.net again.
5. Set the breakpoint in the script:
Debug menu-> window-> debug document
Select the page to debug in the "run document" (this is a floating toolbar similar to solution Manager)
6. Then, you can access the script through webpage operations. When the script runs to a breakpoint, You can debug it.
If you want to enter the debugging status when loading the page, you can press F10 (process by process) for debugging.

From msdn:
MS-help: // Ms. vscc.2003/ms. msdnqtr.2003feb. 2052/vsdebug/html/vxtskdebuggingclient-sidescript.htm

1. First Enable script debugging in IE, select Tools-Internet Options-browse-clear options for disabling script debugging
2. Run the ASP. NET program in debug mode.
3. In the debug-window-run document, let vs display the run document
4. The aspx file for executing a single-step program will be displayed in the running document window. Double-click the file to be debugged, set the breakpoint on the script location to be debugged, and debug the file.

I used vs.net to debug the HTML page with JavaScript. As a result, the debugging window does not display the values of the variables in the script when it is run to the breakpoint. This is also called debugging, I was dizzy, so I wrote a function for tracking variables, as shown below.
//************************************** ******
// This is a variable tracking function.
// Directly call the trace () function where tracing variables need to be used.
VaR newwin;
VaR isdebug = 1;
Function trace (s)
{
If (isdebug)
{
Try
{
Newwin.doc ument. Write (S + "<br> ");
}
Catch (E)
{
Newwin = Window. Open ("", "trace ");
Newwin.doc ument. Write (S + "<br> ");
}
}
}
//************************************** ********

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.