Breakpoint in jscript not being hit - answer but no solution

  • Thread starter Thread starter teddysnips
  • Start date Start date
T

teddysnips

Yesterday I posted a message about a problem hitting a breakpoint when
debugging Javascript in VS2003.

Today I've found out what the problem is. I created a new VS2003 web
solution with a single aspx page, with three controls - a text box, a
check box and a submit button. I put the following code in the page:

<script language="javascript" id="Custom">
<!--

// Get document element
function getE(id) {
return document.getElementById(id);
}

document.all.item("Form1").onsubmit=fubar;
function fubar() {
getE('txtMyText').value = "hidden";
}

Everything worked fine UNTIL I set the AutoPostBack property of the
check box to "True". When I looked in the Running Documents for the
rendered HTML, it turns out that the

function __doPostBack(eventTarget, eventArgument)

code block is NOT showing in the Running Documents, despite being in
the View Source. So, naturally, when you try to set a breakpoint in
code BELOW the __doPostBack the poor old debugger can't associate the
line with executable code.

Further digging reveals that this problem exists for VS2003 and IE7.
I'm just going to have to try to roll back to IE6. What a crock.

Edward
 
<script language="javascript" id="Custom">

That's deprecated syntax, and should be avoided - use this instead:

<script type="text/javascript" id="Custom">
 
while asp.net 1.0/1.1 rendered the __doPostback in the source, version 2.0
(vs2005) the code is in a resource file referenced as a javascript include.

also as asp.net may attached code to the onsubmit, your code may cause
errors. you should do something like:

var frm = document.getElementById('Form1');
frm.oldOnSubmit = frm.onsubmit;
frm.onsubmit = function() {fubar(); if (this.oldOnSubmit)
this.oldOnSubmit(); };


-- bruce (sqlwork.com)
 
while asp.net 1.0/1.1 rendered the __doPostback in the source, version 2.0
(vs2005) the code is in a resource file referenced as a javascript include..

also as asp.net may attached code to the onsubmit, your code may cause
errors. you should do something like:

var frm = document.getElementById('Form1');
frm.oldOnSubmit = frm.onsubmit;
frm.onsubmit = function() {fubar(); if (this.oldOnSubmit)  
this.oldOnSubmit(); };

-- bruce (sqlwork.com)

It's VS2003, and not likely to change anytime soon.

Edward
 
That's deprecated syntax, and should be avoided - use this instead:

<script type="text/javascript" id="Custom">

This change makes no difference at all. Breakpoint not hit. Cannot
debug under IE7 when running VS2003. Pants.

Edward
 
install vs2008 and use it to debug script. turn the script debug off on
vs2003, then attach to ie7 with vs2008.

-- bruce (sqlwork.com)
 
Back
Top