Click here to Skip to main content
13,196,126 members (50,364 online)
Click here to Skip to main content
Add your own
alternative version


18 bookmarked
Posted 7 Feb 2007

ASP.NET Controls - The Bridge between Client and Server-Side

, 7 Feb 2007
Rate this:
Please Sign up or sign in to vote.
A simple article about how client-side data and events are made available on the server-side.


In my previous article, I talked about the length of attributes 'name' and 'ID' and why their size can easily grow. In this article, I will focus my attention answering "Why they are rendered and what are their roles in ASP.NET?".


As far as the attribute 'ID' is concerned, its role ends on the client-side, i.e., this attribute is only used by browser engines and by programmers to easily find an HTML element in a page. This very useful attribute is not always required, and thus, is only rendered when programmers explicitly set an ASP.NET control's ID property value.

If you heavily use client-side scripting, then you certainly have thought about why this attribute isn't always rendered. Well, try thinking of the opposite scenario, where all HTML elements have their own ID attribute rendered, even elements that usually are not changed by script (like Labels) and all the others that in your case are not needed. This scenario seems to me as a waste of resources, especially, valuable resources like network bandwidth.

The role of the 'name' attribute is far more complex. In fact, most of the richness of the ASP.NET user experience is built on top of its uniqueness. Unlike 'ID', the 'name' attribute is almost always rendered, and even when it is not rendered directly to element attributes, it could still be in use on script statements (usually in the popular __doPostBack). The 'name' attribute has two tasks to accomplish:

  1. The first comes from the old ASP times, and is the fact that the 'name' value is used as the key in POST values in the server-side collection (HttpContext.Current.Request.Form).
  2. The second, a new responsibility added by ASP.NET, is to delegate on the 'name' value the responsibility of identifying uniquely the element source of the current post back.

This last responsibility adds a new constraint to the 'name' attribute value: it must be unique, but it also must be something that maps directly to a single Server-Side control, the same that previously rendered the 'name' attribute value.

To achieve this task, every ASP.NET control has a UniqueID property that is built based on the control hierarchy. In order to ensure that a control always has the same UniqueID, it's assumed that its parent hierarchy is always built the same way; even dynamic controls should always be added at the same point of the Page Life Cycle.


As exposed in my previous article, sometimes the 'name' and 'id' attributes grow more than we expect, and we need to think about reducing their size. Any attempts should always preserve the second responsibility of 'name'. If that is not achieved, then you will lose one major ASP.NET benefit:

The bridge between client and server-side that allows raising server-side control events like OnClick and OnChange (OnTextChange, OnSelectIndexChange, etc.).


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Nuno M. F. Gomes
Architect everis
Portugal Portugal
Over 13 years of experience in the Software Development working mainly in the banking and insurance industry.

Over 3 year of experience as Operations Team Leader focused on Infrastructure Management and Software Configuration Management.

I've been honored with the Microsoft Most Valuable Professional (MVP) Award for three consecutive years, 2010, 2011 and 2012, in recognition to exceptional technical contributions and leadership.

Current / Recent Technical Projects
- Dominican Republic Instance management, including 2nd line System management, capacity management, SW monitoring and deploy management
- Colombian SECOPII Instance management, including 2nd line System management, capacity management, SW monitoring and deploy management
- Vortal Main Instance management, including 2nd line System management, capacity management, SW monitoring and deploy management
- Vortal Development ecosystem management, including Server management, , capacity management, SW monitoring and deploy management

Areas of Specialization:
- Operations Management - ISO 20000 & ISO 27001 driven
- Team Management and Coaching
- Technology Leadership, Solutions/Architecture
- Product life cycle management, Continuous Integration
- Technological background in Microsoft frameworks and tools.

You may also be interested in...


Comments and Discussions

JokeRE: Pin
JF_ROCHA8-Feb-07 0:37
memberJF_ROCHA8-Feb-07 0:37 
Seems clearly a infrastructure problem Laugh | :laugh:

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171019.1 | Last Updated 7 Feb 2007
Article Copyright 2007 by Nuno M. F. Gomes
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid