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!
Related
I am looking for some direction on what is the best route I should go with this. I have posted a few times, going off of some recommended design patterns. I have not really received a good direction based on what I am trying to accomplish. I am new to working with Async Processing, and would appreciate some pointers in the right direction. So far, on one of my previous post I have been called ignorant because I requested code samples. Please understand I have been reading everything, and trying everything I can find on the internet. Needless to say there are a LOT of different directions I could go with this, and I am not sure which one is the best.
I will explain what I am trying to do, at a high level, and if anyone out there can PLEASE help me by pointing me in the right direction I would appreciate it. Also, if anyone can point me to some code samples, I would love that. I do not mind reading the material, but it makes a lot more sense if I can see code to follow along with what it is saying. Most of the documentation I have found has code samples, or partial code samples, and I have been doing my best to try to use what I have found to work with my specific need. So far, not much luck. I will admit, when it comes to ASYNC processing, I guess I am ignorant. :)
Anyway, here is what I am trying to accomplish. I am leaving out any specific technology that I may consider using to avoid the debate as to if what I am posting is out of date, or behind the times. I am looking for a point in the right direction, and I am open to whatever at this point. I just need to get this working.
Here is the basics of what I am needing to do
I have an ASP.Net Web Site "Project" that I am working with.
I have a screen that is used to print reports using Active Reports 7.
My task is to allow the user to click a "Print / Preview" button and fire off the report processing.
While the report is running, I need to give the user the ability to click a "Cancel" button and terminate the processing and return to the report screen. (So the UI needs to be responsive during this time the report is processing so the user can click on the cancel button.)
While the report is processing I need to display a popup message to indicate the report is running.
When the report finishes processing, I need to hide this popup message, to indicate to the user the report is completed. Then I need to open the report to be viewed by the user. Currently this is a javascript function that we prepare during the report processing code that opens a new window and calls the report viewer. (So after the report has completed I need the ability to call a javascript function.)
If anyone can kindly point me in the right direction I will be very thankful. I do not mind doing the leg work and reading a mountain of documentation. I just need to be able to know what I am looking at will provide me with the above functionality. Like I said earlier, ignorance or not, if I can get some sample working code (not asking anyone to code this for me, just some code I can step through and help to understand what is happening) it would help a lot.
Thanks you in advance for your time and consideration.
Since you want some operation to happen at the server side along with the UI responding and showing progress. Showing progress of the event. I would suggest using Signalr.Net.
http://signalr.net/
http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr
This is a realtime web api and with this you can create a hub which has functions say "ProcessReport" and "cancelProcessing" you can call this from javascript while connection is open on click of the button and show the progress popup with a cancel button. Have a client event registered with the hub in js say "updatestatus" which can be called from the server to close the popup and eventually close the signalr connection, once the operation is finished. And similarly in the popup cancel click you can again call the hub function cancelProcessing and perform your cancellation and call back with updateStatus.
Hope this helps.
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
I'm developing an addon for IE8+.
Main function:
- when I click the toolbar, it will display a box inside every single page, ex: google.com, bing.com, codeproject.com... by using execScript to execute jQuery.
Therefore, what Im doing is run javascript in the current page.
Everything has done except when that page perform an Pop-up, it doesnt work anymore.
I click the toolbar, nothing happen, but when I look at the pop-up, surprise! has the box which im trying to display. So, I think the current tab and the popup of its is running the same process.
I have change registry key TabProcGrowth to 20, to make sure every single tab run by its own process, but maybe it not work with popup.
sr for my bad english, any suggestion is welcome.
Thanks in advance.
update:
I have changed the way to develop my addon, so I change my question, too. (But any suggestion for the 1st question still very useful for me).
My new question still mention the "execScript" problem.
HOW to execute javascript with every individual tab of IE browser with TabProcGrowth = 0. I need this value set to 0 because I have the timer to request to the server every interval1 (ex: 60s). So if there are more than one processes of IE, the addon will send multi request to server at the sametime.
In my situation now, I set TabProcGrowth to 0. Open IE, open some tabs. Click the toolbar at the newest tab, it works, ofcourse!. But when I click toolbar at the old one, nothing happen. The script still be execute but it takes effect on the newest tab.
It's the big problem for me, resolve this problem, you guys save my life.
I have C# form in the site and want to prevent spam bots from filling it. The trick is, that I want to avoid CAPTHA or any other user input to avoid loosing a single registration.
Here are some techniques I have in my mind:
Hidden input field (question: is this still effective?)
Track time, since the first user input (focus on FirstName) till posting a form.. Humans will take more than 3 seconds to complete a form (even with auto-fill), where bots take a second or less to fill in registration and post it. (question: if I start timer with the first user input, when should I stop it?)
Put in the form tag a fake post url, or post form to itself, and only on Submit button click action to add a real post url with javascript. (question: wonder if new spam bots can cheat this?)
I would be glad to hear other techniques I could adopt, again, without using CAPTCHA, spam filters, form verifications and even validation. Thank you
would be good to have some sort of flash which asks you to reconnect dots (so that it is interactive and doesnt require typing), and when the user does it correctly, you can post with submit to check.
Never liked CAPTCHA, especially the wierd ones where even humans have problem intepreting it :)
A year ago there was a nice control for asp.net that put a hidden field on the form. With a javascript formula. Robots posted it back - and it wanted the result (stored the result first in the session). basically, as robots dont interpret the form in a browser (too slow).... ;) Most got just thrown out there.
Also, another tip: put in hidden fields for the email to address. Some (old)php forms use a mailer supportnig this. OBVIOUSLY only a robot fills that out ;) If not empty -> garbage.
Anyone else have any smart ideas? ;)
I would say stick with Captcha or a similar thing where the user has to type something in.
The problem with using JavaScript is that not everyone has javascript turned on and quite a few have it turned off for various reasons.
Now if you want to really track time, send a hidden form field with the server time filled in. When the postback occurs take the delta of that with the current time. Obviously if the field is missing then you know someone directly posted.
I have a 5 ASPX page wizard.
Each one contains a SaveAndExit button that executes a C# function on a common static class. After saving, the C# code redirects to another page.
Is there a way for running javascript: alert('Data Saved'); after the saving, and before new page is Loaded.
You'll have to register a startup script on postback to do the alert. Then redirect via javascript after the alert.
You can't do it exactly like you want.
The C# code (server-side) can't run until the page has already posted back and unloaded from the browser. So by the time your server-side code is running the page doesn't even exist any more as far as the browser is concerned and it's too late to run your javascript code. This is true even in the middle of a post back, and even if the result of the post back will be the same page. That is why in certain circumstances ASP.Net pages can appear to flicker during post backs.
So you can't force a javascript alert after the data is saved without doing it via some kind of ajax call back-- and that's certainly one option. Another choice is to have the page to which you redirect show some kind of "data saved" message in certain circumstances; trigger it with something simple like a session variable or the value of hidden input on load so it's not obvious to the user.
But I think probably the best thing to do is nothing at all. It sounds like if the save fails you won't redirect. You'll probably even show some kind of error. If your user doesn't have enough confidence in your app that they don't trust it even when there's no error message and it's moved on to the next step, you're in trouble.
Vik, unless this is a homework I would highly suggest you don't.
JavaScript alert is very annoying to most users and seems completely useless in this case as explained by Joel Coehoorn.
If you insist on showing a message when it is saved then think of adding maybe a session variable and on the redirected page show the "Data saved" message at the top if the session variable exist and then delete the session variable.
Again though, as Joel Coehoorn said, you should definitely show a message if there is an error but redirecting should be all the "proof" they need that their data was saved.