Intellisense, Web Pages, and Scope
Things aren't are obvious as they once were ...
... and they never were very obvious.
Part 6 of the current tutorial, Learn ASP.NET 2.0 - Intro to the Grid Control, has been posted.
While writing this article, a new trend in Microsoft's development tools has started to really bug me. Consider the following code snippet:
The good news is that Microsoft's development tool is doing a great job of telling me that I have a problem. The bad news is that why I have a problem is getting more difficult than ever.
The rule used to be that if you didn't have a reference or Imports for a namespace in your program, an object wouldn't be found. But with partial classes and web pages, that rule doesn't apply anymore. Moving the TemplateField tag inside the Columns tag works.
I can't find anything in Microsoft's documentation that actually spells this out. I did find this:
"The TemplateField object is displayed differently depending on the data-bound control in which it is used. For example, the GridView control displays a TemplateField object as a column, and the DetailsView control displays it as a row."
Great! The same keyword does different things. Ya gotta love it!
I know ... this is HTML, not VB. But Intellisense still works. (In fact, that part of the tool seems to be getting better all the time.) You can still reference methods and properties of objects just like you can in VB code. And, in fact, this is a partial class but the code that makes it into one can't be seen.
Knowing what works where is getting more and more confusing so it's a good thing that Intellisense is getting better.
One of the big improvements in VB.NET 1.0 over VB 6 was that you could, for the first time, actually see the code that made your program work. Much of it was kept out of the way with the new Region directive, but you could check it out and even change it if you knew what you were doing. But the new tools are regressing back to the bad old habits of VB 6 again where the magic happens out of view. You just have to "know" where things go because if you don't code it that way, it doesn't work.
This is the "magic incantation" style. If you don't say the magic words just right, the spell doesn't work.


No comments yet. Leave a Comment