ASP.NET GridView – OnRowDataBound vs OnRowCreated

This morning, while I was creating a simple ASP.NET page, I have fought a couple of hours versus a GridView that apparently worked in strange ways.

Problem Description

The problem I encountered seemed to be the wrong setting of the property “ID” of the Client-side controls. Generally, the ASP.NET engine (prior to version 4.0) takes fully charged to change the ID to avoid duplication, so that they are always unique. Particularly in the case of a GridView fact, for a control that we insert with ID = “txtSelectedValue”, and that is repeated for each row of the grid, will have a ClientID like this:

Continue reading


C# Tips – Using delegate in List.Find() predicate

If we had a funcional language (eg or ), we could easily manage a collection or list.
With the , we can work equally functional with (Exploring). using this feature of the we can develop, process and manage our data more easly, especially with .

An example that I wish to use, and is also the most frequent that I happened to develop, is the use of these anonymous delegates to the search function of a generic list ()

Continue reading

Translate localized error messages from .NET, SQL and Windows – FindErr.NET

A quite common situation: a rintime error with a harder to understand message (or not).
Looking on the various search engines, it’s easy to find solutions, resources, examples.

In many cases, however, the messages are in another language, and often the translation does not match with the original message. Looking for the message on the search engines, you do not find much information and sometimes you can not find material that help to solve the problem.

The solution comes from a very brilliant site:
Translate localized error messages from .NET, SQL and Windows – FindErr.NET

In addition to having a browsable catalog by subject and alphabetically, also has an internal search that presents the result in 22 specific language (Arabic, Czech, Danish, German, Greek, Spanish, Finnish, French, Hebrew, Hungarian, Italian, Japanese, Korean, Dutch, Norwegian, Polish, Portuguese, Russian, Swedish, Turkish, Chinese Simplified, Chinese Traditional) with its translation into English and a ready link for google.

Well, we have to create a shortcut on our desktop!!

ASP.NET ScriptManager Error: this._forum is not a object

I happened a few times to receive this error on an ASP.NET page that contains a ScriptManager and a link to a JavaScript file inside the Head tag on the page, like this:

<head runat="server">
    <script type="text/javascript" src="../Scripts/barcode.js" />
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />

Apparently the code is without errors, but running the page in debug mode, you receive an error like this:

Microsoft Javascript: object needed

Microsoft Javascript: object needed

By clicking on the button “Stop”, I’m going to try to understand what might have happened, and I realize that the object “_form” of the page does not exist, or is “null”

this._form is NULL

this._form is NULL

Needless to tell you how long I spent trying to figure out what could have happened, and where could be a possible error, of course without success.

After a meticulous search on the internet, I finally found an article that enlightened and saved me .
It seems to be a small bug of ScriptManager object, which misinterprets the tag <script /> without explicit locking.

It was sufficient change the tag and use the canonical syntax to solve it all:

<head runat="server">
    <script type="text/javascript" src="../Scripts/barcode.js" >

End of the ordeal.

ASP.NET Underground tour (Part 1)

To fully understand how to use ASP.NET is necessary to know the basic operation of the web (for example as occurs a request from browser to server, what are the technologies used, how a web server processes the request, etc. …).

Understanding why a web page is not interpreted correctly in a browser, because a request is not performed as expected, or generate the appropriate HTML code from a custom control, are questions that do not depend only on knowledge of ASP.NET (or any other technology), but also from the knowledge of how a web application works.

Continue reading