Jan2008
30

ASP.NET Controls - Improving automatic ID generation : Concept ( Part 2)

by nmgomes

Before proceeding to the implementation details, let's discuss a little about how ASP.NET handles automatic Id generation.

First of all, the Control.UniqueID property is the key to all major ASP.NET benefits. In fact, ASP.NET gives us unique Id's for each control which give us a deterministic way of recreating page controls. Without this, Viewstate and Events were impossible to achieve.

ASP.NET also gives us the concept of naming controls, that enable us to easily find the correct control and to write more perceptible code, but More...

Filed in: .NET | ASP.NET

Jan2008
23

ASP.NET Controls - Improving automatic ID generation : Introduction ( Part 1)

by nmgomes

Some time ago, while developing a large corporate ASP.NET application with high complex layout requirements and thus, many custom composite controls, I was faced with the following problem:

The generated HTML of my pages don’t meet my bandwidth constrain of 50Kb/page, even after applying the traditional ways to reduce page size (compression, viewstate optimization). Looking carefully at the HTML source I found that a big amount of size has due to the large values 'id' and 'name' attributes. The sum of all this values could be up to 40% of page size, and this became a real issue to me.

So, ASP.NET gives us out of the box a unique strategy to generate the control's ID values. Although such strategy is most of time a satisfactory approach, there are cases when it can become problematic. More...

Filed in: ASP.NET

Jan2008
17

.NET Framework 2.0 SP1 - TagMapping Undocumented hotfix

by nmgomes

While searching a way to solve the HtmlControls tag mapping problem I found that the new SP1 bring an extra undocumented hotfix.

This undocumented hotfix changes MainTagNameToTypeMapper.GetControlType method so that, for every tag name regardless is kind, a tag type mapping is always performed.

This little change enables us to tag map HtmlControls the same way we map WebControls and UserControls. Here is an example: More...

Filed in: .NET

Jan2008
14

ASP.NET - Tag Mapping

by nmgomes

Tag Mapping is not a new ASP.NET 2.0 feature, but only recently many people discover it.

<system.web>
  <pages>
    <tagMapping>
      <add tagType="System.Web.UI.WebControls.TextBox"
           mappedTagType="MyTextBox"/>
    </tagMapping>
</pages>

The use of Tag Mapping allow us to, at parsing time, replace a given control type with other control type. The only constrain is that new control type extends primary control type.

If I use Tag Mapping with Web Controls everything works fine but if, instead, I use Html Controls, like HtmlForm, with tag mapping no mapping is done.

Using Reflector I found no reason for this behavior.

Filed in: ASP.NET

Jan2008
5

Email Regular Expression

by nmgomes

From time to time the question strikes back: How to validate an Email?

If you think you know the answer then you must read this Phil Haack post.

Filed in: .NET