11 July 2004

Debug JavaScript in ASP.NET Apps

Debug JavaScript in ASP.NET Appstells how to debug client script:
Assuming we 'inject' following code snippets to create client side script

<script language="javascript">
function DoSomething()

//in the code behind test.aspx.cs
private void Page_Load(object sender, System.EventArgs e)
btnClick.Attributes.Add("OnClick","JavaScript:return DoSomething();");

We can set break point at DoSomething() by:
1) Open Internet Explorer, choose Tools | Internet Options. Click the Advanced tab and find Disable script debugging. Clear the checkbox.
2) In VS.NET IDE, press F5 to launch process in debug mode.
3) Navigate to the web page contains the script- test.aspx
4) Open 'Running Ducuments' window on IDE by selecting Debug | Windows | Running Documents, Running Ducuments Window launch and give a tree list of all document;
5) Double click test.aspx to load it into IDE browser window.
6) Place break point, monitoring variables as usual.

No comments: