ZDNet UK


Skip to Main Content

ZDNet.co.uk - Winner of Best Business Website 2007
  1. Home
  2. News
  3. Blogs
  4. Reviews
  5. Prices
  6. Resources
  7. Community
  8. My ZDNet

 

ZDNet UK RSS Feeds


IT Jobs

Office applications Toolkit

Where is the logic in .Net?

F. Godfrey Baker Builder.com

Published: 15 Oct 2002 09:01 BST

  • Email
  • Trackback
  • Clip Link
  • Print friendly
  • Post Comment

Traditional Web applications mitigate server loading and enhance the user experience by embedding logic in client scripted algorithms. Form validation, data sorting, and paging functionality are often performed on the client, as are user message boxes, dynamic text elements, and pop-up menus. Such client-side scripting makes for a vibrant user experience while requiring little server interaction. By distributing the computational needs of specific functionality to their clients, traditional Web systems have achieved a bit of a free ride -- dynamic functionality without additional server loading. Most highly trafficked, public Web sites couldn't scale to their user base (or achieve the desired interactivity) without considerable use of client-side scripting.

Microsoft's .Net facilitates a broader set of functionality for Web applications. It establishes a bias for server-side programming that may be uncomfortable for those used to extensive client-side scripting. While adapting to the new paradigm, developers will have to learn how to judicially apply postbacks for optimum event handling on the server without sacrificing application response or scalability. Additional challenges surface when assigning event-driven, browser-based functionality to rendered server controls.

Limiting browser exposure through .Net
Microsoft's .Net strives to mitigate the development and maintenance overhead associated with extensive client-side scripting. Using Visual Studio .Net Designer with its drag-and-drop functionality, a developer can roughly develop an entire ASP.Net application without ever editing actual presentation script. Visual Studio .Net enables automated client script production. While a more common development scenario combines drag-and-drop with limited hand scripting via the Visual Studio .Net Code Editor, a developer is still limited to editing only the server tags of any Web control. The developer is completely isolated from its underlying JavaScript or HTML.

Traditional client-side developers may bristle at the notion of automatically rendered JavaScript, but Web controls go a long way in eliminating cross-browser development difficulties. ASP.Net employs sophisticated algorithms for rendering browser-specific code compatible with most browsers and most versions. Also, ASP.Net renders HTML (rather than DHTML) for browsers that do not support DHTML.

Web controls reduce custom presentation coding through more than just automated JavaScript rendering. The Web control event model enables sophisticated and elaborate event-based server processing, rivaling client/server or stand-alone applications. The key, of course, is the server in the server-based event model. To take advantage of the dramatic features in the Calendar, DataGrid, Button, or any other Web control, all significant processing must be done on the server. Microsoft's .Net has mitigated the overhead required for maintaining and developing client-side script -- but in doing so, it drastically altered the client/server balance of traditional Web programming. Successful implementation of a .Net application requires coming to terms with this new bias.

Postbacks
.Net's focus on server programming will immediately become apparent to the developer considering server postbacks. Postbacks are associated with any Web control event and are basically requests for processing sent to the server. For example, assuming an event handler has been written, a list box will fire an event anytime a user selects a new item. Posting back to the server allows that event to be handled by initiating a round trip to the server. While server requests are certainly not new to .Net, you do need to consider their frequency. .Net applications, if coded unwisely, can post back to the sever with nearly every event on every control. Obviously the network traffic and server loading will result in extreme latencies under even moderate traffic.

.Net mitigates postback overuse by allowing developers to disable automatic postbacks on some controls. Rather than automatically initiating a postback when the user changes the control, events are cached and submitted on the next post when autopostback is disabled. Some controls however, such as the Calendar and DataGrid control, don't allow the disabling of the autopostback functionality. These controls will initiate a server round trip with every change to the control.

Additionally, the control's view state can be set to help minimise network traffic. The view state enables server controls to maintain their contents over a browser refresh. Since this is done via passing the control's serialized values back and forth between the browser and the server, disabling the view state when not necessary will improve performance.

Back to the client
Certain basic application functionality is currently impossible to handle strictly from the server. For example, consider setting the focus on a TextBox server control. Currently, there is no .Net method or property available to set focus to any server control, and the request must be handled through client script. With a control placed directly on a Web form, this is a relatively straightforward scripted operation: Access the server control by its ID and invoke the focus method.

The situation becomes more complex, however, when the target control is the child of a DataGrid, DataList, or other compound control. Let say, for example, that you want to set the focus to a TextBox inside a DataGrid control when the grid is first put into edit mode. As with a stand-alone control, you'll use the ID of the control when you invoke the focus method call. However, at design time, the specific TextBox doesn't yet exist since the grid isn't yet populated. So you have to create the client script at run time on the server (i.e., on the edit event) and then render it to the client. Since the client script must specify the ID of the target control, your application code will have to determine the selected row and column in the DataGrid and then locate the associated TextBox control's ID.

Similar difficulties arise for triggering the simplest of client interactions, the alert box. Because an alert box is solely browser-based functionality, .Net does not have an activation mechanism. In this case, a client script must be rendered that accesses the browser DOM and invokes the alert method. The client script itself is trivial; however, when combined with, say, the delete action from a DataGrid server control, you're again in the situation where you must write server code to discover the child control's ID and embed it in rendered client script.

Never say never
Microsoft envisions a highly interactive future based on server event handling and machine-rendered client script. Currently, due to server processing capability, network latency, and browser incompatibilities, this future has to be carefully adopted. But with the accelerating increase in network bandwidth and processor throughput, the Microsoft future of unbridled server-side events and drag-and-drop JavaScript is likely only a mouse click away.


Have your say instantly in the Tech Update forum.

Find out what's where in the new Tech Update with our Guided Tour.

Let the editors know what you think in the Mailroom.

  • Email
  • Trackback
  • Clip Link
  • Print friendly Print with Dell

Did you find this article useful?
53 out of 71 people found this useful


Full Talkback thread

0 comments


Company/Topic Alerts

Create a new alert from the list below:











Related Jobs

System Administrator Linux Level 2 ( RedHat, Linux+, SQL ) West London

Your responsibilities will include;  Troubleshooting and resolves system service issues and OS level issues, including issues escalated from ...

C# Web Developer, Warwickshire, 30-35k + Benefits

To apply, you will need experience in Web development using: ASP.net / C#/ Visual Studio 2005 SQL Server 2005 (T-SQL / Stored Procs)/DMTHL / ...

Business Analyst ( OO , Java ) - London

Responsibilities include developing algorithms for pricing and risk management, testing, documentation as well as interaction with clients. Primary ...

Featured Talkback

Why do so many (virtually all) software packages think that they are so important that they have to be started automatically every time the computer boots? What is the largest number of "speed access", "update check", "camera download" and whatever other background programs you have ever seen running? Of those, how many did you really need?

By: J.A. Watson

Read full story:
Annoying software: a rogues' gallery

Discussions

keithmv keithmv

Password Deadlock

Saturday 26 July 2008, 12:02 PM

2 comments

Vista Upgrade Blog

Microsoft's pre-modern message puts a...

Over at ZDNet.com, Ed Bott reports a first sighting of Microsoft's eagerly awaited $300 million ad campaign. Already the cause of much speculation, the consensus is that this will be... More

8 comments

A $40 CONSUMER-class router has create...

Believe it or not I don't work in IT, haven't for 7 years. Yes I work with Microsoft's Windows XP Embedded and as a result I have to know a lot about the OS, the kernal, Win API calls... More

Post a comment

Sick Puppy Redo

I generally follow a dispassionate investigative process when trying to discern what happened when a project goes bad. Although its a low priority item, it gets done simply because... More

Post a comment