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.
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:
Apparently the code is without errors, but running the page in debug mode, you receive an error like this:
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
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: