Wednesday, November 18, 2009 1:25 PM plblum

Give us more control of Intellisense

This is part of a series of postings asking for improvements to Visual Studio and ASP.NET.

As a commercial web control developer, I have to include extensions to Visual Studio's design mode, such as UITypeEditors and TypeConverters. Both of these classes augment the Properties Editor for an individual property. Both can provide a dropdownlist or popup a window such as the CollectionEditor.

Here the UITypeEditor DataTemplateNameEditor provides a dropdownlist of stored "Pattern Template" file names to the FieldsPatternTemplateName property.

public class DynamicFormView : FormView
{
[Editor(typeof(DataTemplateNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
public virtual string FieldsPatternTemplateName
{
get { return fFieldsPatternTemplateName; }
set { fFieldsPatternTemplateName = value.Trim(); }
}
protected string fFieldsPatternTemplateName = "DetailsView";
}

 

UITypeEditorDropDownList

I can also use these attributes in the SmartTag attached to the web control in design mode.

Now it's time for Intellisense to support the UITypeEditor and TypeConverter classes. Why shouldn’t that dropdownlist appear to help setup the property? I have numerous cases where they could really assist the user. Some examples:

* In the ControlToValidate property on Validator controls, show a list of available controls.

* In the properties to choose the type of the Entity or DataContext in DataSource controls.

Why shouldn’t the user be able to popup a model dialog editor for a property? For example, in the Validationexpression property of the RegularExpressionvalidator to provide a tool to test your expression.

I have learned that I can do some of this today by using the TypeConverter and its GetStandardValues() method. See “How to: Implement a Type Converter”.

Unfortunately Intellisense gathers the list from GetStandardValues() once, very early in the design mode preparation. At that time, there is no “context” which provides design mode information that you can use to get a list of controls on the page. My own situations nearly always need data that is available at a later time.

So I request Microsoft to improve the GetStandardValues to allow it to be retrieved at the moment its needed. Perhaps there can be a new property or attribute assigned to the Typeconverter class to indicate this?

I understand why UITypeEditors and Typeconverters are not implemented in Intellisense today. They require that “context” I mentioned earlier. The UITypeEditor is hugely connected to design mode’s objects, which are associated with the context. Visual Studio would have to spend time to convert the markup into the control class instance and build a number of design mode support objects. That will slow down Intellisense. Yet I’d like Microsoft to try. Perhaps they can introduce a similar class to UITypeEditor that is specific to Intellisense.

In any case, I can’t wait to enhance my web controls so that you markup users can benefit.

And if someone out there knows of a way to do this now, let me know!

Filed under: , , , ,

Comments

# Dew Drop – November 19, 2009 | Alvin Ashcraft's Morning Dew

Thursday, November 19, 2009 10:15 AM by Dew Drop – November 19, 2009 | Alvin Ashcraft's Morning Dew

Pingback from  Dew Drop – November 19, 2009 | Alvin Ashcraft's Morning Dew

# re: Give us more control of Intellisense

Monday, November 23, 2009 10:18 AM by CF

Any plans to demonstrate a very basic example of creating your own custom control from scratch?  Im an experienced developer, but not familiar with creating my own custom controls for use in asp.net.  Some of the examples here seem to assume a certain level of familiarity.

Keep up the good work!

[Peter's comments] I'm not sure I'm heading to general tutorials with this blog. The topic of building web controls is extensively covered on the web. I find most tutorials way too simplistic for my skill level, but I figure they'd do well for a first timer like yourself. For example: http://msdn.microsoft.com/en-us/library/zt27tfhy.aspx

Here are the points I'd like to make on this subject:

  • Learn about attributes. They play a huge roll. Those articles will introduce you to most of the common ones.
  • Realize that custom controls are HTML generators. In the end, you want its Render() method to add a block of HTML to the HtmlWriter object passed into Render.
  • There are two approaches: Rendered, where you explicitly create the HTML in the Render method, and Composite, where you create other controls that contribute their HTML to your control in the CreateChildControls method.

Leave a Comment

(required) 
(required) 
(optional)
(required)