Developing Conditionally Driven Event Handlers in ASP.NET 3.5
(Page 1 of 4 )
What is a conditionally-driven event handler, and why would you want to use one? Basically, such an event handler will perform its assigned action -- such as displaying text on the screen -- if and only if a certain specified condition is met. As you might imagine, such event handlers have a range of uses. This article will walk you through some examples in ASP.NET 3.5.
You should have gained a basic understanding and formulation of event handlers in ASP.NET from this tutorial. Now if you need to go more deeply into this aspect of developing ASP.NET 3.5 web applications, one of the most important tools you can use is "conditionally driven" event handlers.
Let's consider one of the examples given in a previous tutorial, namely the web application to compute the area of the circle. Suppose you want to alter the project and say the application can only compute the areas of circles with radii greater than 100 and rejects values below that. You will need to employ some kind of conditional server side scripting which will analyze user inputs. And then it will fire the event depending on the user input. This is an example of a conditionally-driven "click" event handler.
Other types of event handlers discussed are the "page load" type of handlers. This will fire the event at any time the page is requested to the server. To make conditionally-driven page load handlers, server side scripting will analyze user inputs are needed, in a way that is similar to what is done in click event processing.
For example, say you are going to make an application which will display "Good morning" in the browser if the server time is 6 AM or "Good evening" if the server time is 8 PM. Things like this need to have some conditional statements added to your ASP.NET server side scripts.
Next: Choice of Programming Language >>
More ASP.NET Articles
More By Codex-M