Templates going haywire (There is already a component named ….)

Sometimes the template editor in VS messes things up. After clicking “edit template” a horror like this might show up:

This is fixable :  When you drop a control, like a textbox or label, on the page VS will create a declaration for the control in the code file behind the page. In a control which works with templates, like a datagrid or a datalist, the controls in the template are not added to the code. (In my dnj article on the datagrid I described how to get to the template’s controls from code nevertheless…) What happened in the screenshot is that VS.NET did create declarations for all the controls in the code behind source file. Deleting (commenting out) the declarations from the source will get the template editor working again.

I don’t really like the template editor that much. When a template is opened VS creates a class based on this page containing the template and the html source of the template. Probably comparable to the things asp.net does in IIS when a full page is requested. In the process of editing a template VS keeps doing things in the background, so much that it can cripple any machine. Editing templates is not the “experience“ of editing a normal page. At this moment I’m exploring user controls as an alternative, but still have some hurdles to take …

blog on, Peter


This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • Peter van Ooijen

    Brendan, that’s cool. But to customize the template I still have to use the template editor.

    Your story shows it’s all about usercontrols. I’ve been playing with them a little more and found it very easy (and fast) to drop a user control on the template and handle all program logic inside the user control. More on that in an article I’ll submit to the dnj.

  • Brendan Tompkins

    Peter, I recently posted about editing the default templates. You may be able to customize the default templates, so that you get what you want out of VS.