There is a web page (call it main) that contains several frames.
The main and all its included frames raise event DocumentCompleted.
The order of those events is: Subframe1, subframe2, subframeX.., main.
What I want is to parse the content of the main and add some handlers on several html elements on it before the user can take any action. (For example button.Click or link.Click). Till now this is possible by waiting the DocumentCompleted and checking the event's arguments for the correct frame.
However, sometimes the included frames happen to take much time to load and the desired event is not raised within a reasonal amount of time. However the page is visible by the user despite the fact that parsing and the addition of the handlers cannot be done.
So the impatient user interacts with the page, which messes up all the work.
Is there a recommended way to parse the page sooner without waiting for DocumentCompleted (as long as the data is there of course) and keep doing it silently (that is: not show a waiting form or popup to the user)?
You can use the 'Navigated' event, look here
Related
I tried to make a while (work){....}
inside button event called start
to do some stuff like label changing in the same form with random values
and I have another button called stop I want to make the work=false; so the while should be break
the problem is when I clicked start button and the form froze and did nothing
how I can do that like stay in the while loop and access all other events
As long as the loop runs, no events (like your other button's click) can be processed. This results in freezing the UI.
Better use a Timer instead of an infinite loop. The timer will not freeze the UI but call a Tick event at defined intervals and allow other events to be processed between two ticks. It is then easy for another button to stop this timer.
Since you have not mentioned any UI technology (is it WinForms, WPF, WebForms, MAUI, Xamarin, ...?) and not shown any code, it is difficult to give you example code.
I need to construct and show a notification if some errors happen in page life cycle.
Usually, I use Page_PreRender event for last changes but there are also many Control_PreRender events which called after Page_PreRender.
Is there the event that triggered after all Control_PreRender events that can be used to construct and show a notification?
Or if I find and use the latest Control_PreRender event, is guaranted that the order of all Control_PreRender events will stay the same?
based on this link Technically PreRender is your last chance to tweak the page or control before it turns into HTML stream. another alternative you can use jquery document ready to show your notification.
$( document ).ready(function() {
// Handler for show notification
// can by via ajax or just common javascript
});
I have stepped through my code, and it stops when the page is fully loaded, as it should. However, their are a few buttons on the page, that I DO NOT see the names of in my code, so I can't discover where to add a breakpoint to, to follow the logical flow. How can I see what is happening, 'behind the scenes' when one of those buttons is pressed?
EDIT---Would this be an applicable scenario to use tracing?
If you add a Page_Load event to the WebForm, you can put a breakpoint there. That event / method will be called every time there is a server-side interaction with any of the controls on the page, followed by the button click (or whatever other interaction is occurring). When on that breakpoint during a PostBack, you can look at the Form["__EventTarget"] value to determine what control is being invoked and the Form["__EventArgument"] may contain additional details on what event is being triggered.
I'm writing a program to navigate a website, but I'm having trouble with code execution occuring when I don't want it to execute.
I have a WebBrowser control where once the page finishes loading, I have code analyzing the html, and for certain circumstances I tell the WebBrowser to navigate to a new URL.
So I basically have a line of code that looks like this, within a method, the method within the DocumentCompleted handler
if this condition then
wb.Navigate(new Uri("http://www.website.com"), "_self");
else do something else, exit method, continue processing code
However, when I Navigate, the code continunes to execute beyond the Navigate. It exits the method, and keeps processing code.
How to I stop the DocuemntComplete event handler from processing whenever I call a new page navigation?
I have a web application and I'm attempting to put an ajax timer control in it to give me a post back every 10-20 seconds. (possibly longer depending on performance). I have a lot of dynamically created each with auto postback. These controls are inside of their own update panel.
Well, whenever an AJAX timer tick happens, I want to be able to know this at page_load so that I can have some conditions off of this(such as not creating some controls or whatever).
So how can I know at Page_Load time that the reason for the post back was a tick event? I have tried doing something like if(Request.Form[mytimer.UniqueID]!=null) but that is always a false condition(it is always null)
Basically, I just want to know if an AJAX timer tick event will happen, before the event actually occurs(which is after page_load)
I think this is what your looking for:
http://geekswithblogs.net/mahesh/archive/2006/06/27/83264.aspx
The article explains how to figure out which control caused the post back which in your case would be your timer control.