Make Episerver string textbox property wider!

Using UIHint you may choose if a string property should be displayed as a single-line or a multi-line editor. But why is the multi-line editor so wide, and the single-line editor so narrow? We can fix that!

Consider this property definitions:

public virtual string Copyright { get; set; }

public virtual string Description { get; set; }

It produces the following result:

The original width of the string property text box

If we add an EditorDescriptor like this:

[EditorDescriptorRegistration(TargetType = typeof(string))]
public class StringEditorDescriptor : EditorDescriptor
   public override void ModifyMetadata(
      ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
      // Only target string, not IList<string>
      if (metadata.ContainerType == typeof(string))
         metadata.EditorConfiguration.Add("style", "width: 580px");
      base.ModifyMetadata(metadata, attributes);

The updated result:

The new and wider string property text box

This code will change the width of all string properties, you may of course control this with antoher UIHint, if you prefer that. To apply for selected properties only, add the UIHint like this to the definition above:

[EditorDescriptorRegistration(TargetType = typeof(string), UIHint = "widerstring")]

And decorate the properties you want to be wider, like his:

public virtual string Copyright { get; set; }