Breakpoint in jscript not being hit - answer but no solution

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
 
M

Mark Rae [MVP]

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

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

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

bruce barker

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)
 
T

teddysnips

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
 
T

teddysnips

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
 
M

Mark Rae [MVP]

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

I was merely pointing out that you were using out-of-date JavaScript
syntax...
 
B

bruce barker

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

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top