Mark Wilson I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :
03/24/2008
Times viewed :
255
Server-Side Controls
Now having web pages with button and checkboxes is nothing new.
But what is new is how we can write code to interact with these controls. In
classic ASP, writing code to manipulate them was very tedious. With ASP.NET we
can access server-side controls simply as properties of the page. For example
we can exclude a button on a page by setting the Visible property of the button
to false. Furthermore, we can write new web server controls made up of standard
HTML elements that we can re-use on a number of pages. The .NET Framework
already ships with a number of pre-built server-side controls like that.
Besides controls to handle all the standard HTML elements: check boxes, radio
buttons, drop-down lists, etc, there are also more complex element like a input
validators, a date picker, a grid control and a tree view, just to name a few.
Every interaction with a user element can generate an event
which we can process with an event handler method. Clicking on a button, for
example, generates an event which we can appropriately handle with a click
event handler. Even though this sounds simple, keep in mind that under the
covers is still HTTP and HTML. Since events occur in the client’s browser and
the event handler method runs on the server each event generates an HTTP POST
request that is sent across network
(think: slow transfer!) to the web server as illustrated by the following
diagram.
Figure 17.3: Events from an ASP.NET page in a web browser
are handled by the page on the server.
The web server processes the request and sends back another HTML page to
display the results of the event. This can be a pretty lengthy operation,
especially if your client sits in Zimbabwe on a 28.8k dial-up connection.
Therefore you need to carefully choose when you want to employ server-side
controls. Do not rely on server-controls for every task you need to perform,
regular HTML controls are a lot more efficient if you can process an event on
the client. For example, you probably do not want every click on a check box or
a radio button to result in a trip to the web server. You can still design
pages with web forms designer, even if you mix server-side controls and regular
HTML elements. However, you do need to process a user event on the server when
you have to update records in a database.