javascript key down problem - c#

I have a key down event attached to one of my textboxes and over time and modifications/additions of 3rd party scripts the key down doesn't work any more. I've tried replacing key down with key up/key press but no luck.
How would you trouble shoot something like this (to me, it's like a needle in the haystack).

in your Javascript code where you handle the KeyDown event, add "debugger" before your code, and you'll be able to debug JavaScript.
function HandleKeyDown() {
debugger;
// rest of your code here
}
If you're using IE, then in Tools - Advanced, you must make sure that "disable script debugging" is not checked, or it won't stop at your debug point.
If you use Visual Studio 2010, there's a neat JavaScript debugger built in :)

To me the best approach to troubleshooting is start taking out everything is not necessary to make i work. In this case, start deleting all the 3rd party scripts and extra code one at a time, while you try if it works or not every time you delete something. Sooner or later you will find what part of the code is causing this, then you can worry about how to fix it.
It would help if you could post a link to your code.

There are a couple of ways you could do it. Is there a javascript error?
If there is no error to indicate a line of code that's bad, then I would eliminate the thrid party scripts so that your script works as intended. Then, add in the scripts one at a time, continuously checking to see if your keydown still works.
Once you know which script is messing with the keydown functionality you can then start using comments and alerts to isolate the issue in that third party script.

Related

Visual Studio Extension subscribe to a debugger event

I'm developing a visual studio extension and now I'm facing a problem:
How do I subscribe to a Brake Point, i.e. every time the debugger catches the Brake Point, I would like to perform some action.
I can split this single problem into 2 problems:
1. How do I fire a function without pressing anything (I understand that the event should do this)
2. What function should I call to see the breakpoints (make my function fire)
(Don't see any reason to put any code because this is a HOWTO question and for real I don't have what to show)
Thanks for any help!!
You can use DTE.Events.DebuggerEvents and DTE.Debugger to receive notifications of a break point and get information about it.

C# Consume Global Key Event

I'm facing a tough one right now, at least it's tough for me!
I'm using this code to capture key press events and it works just fine even when the window is out of focus.
In addition though, I'd like to be able to consume the key event before it is used by any other application that does have the focus right now.
Search after search has brought no result for me, does anyone know how this might be accomplished?
Im sure there is a simpliest way to to this (the code you use is old), but I've found this post. (Look at the code at the end)
Anyway, you can always use the 'KeyEventArgs.Handled = true;' property in the 'KeyDown' and 'KeyUp' event of your focused control to limite the key's propagation.
Here is the source code of a program that captures every key on windows, records it, and then passes it on to the next program.
You could take that code as a starting point and conditionally execute the call to CallNextHookEx to consume the keys.

can i see real time javascript events like ajax calls in firebug?

So when I do an ajax POST I can see the thing firing in firebug, I can see the spinning icon as it's running, a finished icon when it's done. I can see results or errors and whatnot, you all know the deal.
Is there a way to get it to show me every javascript event as it fires? So if I have something like this in my windows onload:
defaultJs.LoadImages();
defaultJs.CheckAccount(username);
vendorsJs.UpdateSearch();
I would ideally see each of those happening, or be able to step through them similar to how you would step through CS files while you're attached to the WWW process with F10 and F11 and all that.
My problem is how long it takes tracking through another person's code when I'm tasked with finishing the work of another developer that's been moved to another project. I basically have to do what I described manually reading the code, or set up a ton of console.logs to try and force this sort of information into something I can read.
I'm hoping firebug has some feature I haven't enabled, or there's a program like fiddler (where you see things loading realtime) that'll do it for me.
Sorry if this is a repeat question, I wasn't able to find an answer that worked for me after some searching. I appreciate any time anyone commits to helping me out here. Have a good day yall.
you can debug the JS code using FireBug
http://getfirebug.com/javascript

Postdata confirmation box bypass?

Ik working on some project, and there is one main problem I have. I'm writing some code that is performing some actions on the web, like posting data. But what happens all the time: Javascript code on the pages reload the page, just after i posted data, so it will ask for confirmation. I just need to know, is there any way at all to do this? I'm using C# with WatIn. I've thought of some ways myself:
Disabling all message boxes, doesn't seem to work for this box.
Detect when the box shows up and then press cancel, but I don't know if that's possible?
Look in the Javascript code and when it tries to call the Reload method intercept that or something?
Some other setting that disables this auto-reload? (tried some thing called METAreload i think but didn't work)
Google doesn't give me the information I need, I have been searching on this for quite a while now. Someone knows how to get rid of this box blocking my program?
Ok, I finally fixed it myself. There was a javascript function that would make the page reload when the timer was at 0. Just by putting javascript in the URL bar i could replace that function bij an empty one, and now it won't reload anymore!

Visual Studio is missing/moving my breakpoints

The problem is that when I place a breakpoint and debug/run, the breakpoint moves by itself.
Before/whilst coding:
After clicking run/breakpoint hit:
Breakpoints typically work ok for me, but it seems that they sometimes randomly play up. I first had this ages ago with a VB project, and in the end, I bypassed the problem by removing the breakpoint and adding it somewhere else where it was still useful.
Whilst I could probably do the same again, and this is only the second time it has happened (that I remember), I don't really want to have to and would like to know what is actually wrong.
I have read through many similar questions here, but I cannot see an exact match and the answers do not help. I have tried - building, rebuilding, closing/reopening and cleaning.
I only provided a picture of the bit of code where it occurs, if you need anything else, please let me know.
It's because the debugger isn't able to break at that point. For example, the debugger can't break on auto-implemented properties, or at the header of a method; instead, it breaks at the first line of the method.
Also check to see if you had set the breakpoints in one mode (Debug) but are now in a different mode (like Release). This caused me some momentary angst.
I got this problem after Windows had inexplicably added 6 months to the current system date (and 1 hour to the time). I didn't correct this right away, so builds made before the correction looked more recent to Visual. This lead to running the wrong (older) build when debugging.
Since I couldn't find a "Clean Solution/Project" option, I had to manually delete all .pdb files in the solution. The problem was instantly fixed. I just hope there aren't any more files I might need to delete (I'm new to Visual and don't know much about how it works behind the scenes).
You can get this if the breakpoint is AFTER a return statement. Visual Studio will bounce the breakpoint to the closing brace (or "End Function" for VB.NET) because return is jumping out of the function.

Categories