November Happy Hour will be moved to Thursday December 5th.

Wider string property

Vote:
 

I'm trying to get the input fields on some of my string properties wider.

I have made a property, a custom UIHint and an EditorDescriptor.

I can make all string properties wider with the EditorDescriptor but when restricting to a specific UIHint nothing happens.

When I specify UiHint and debug I can see that the code in the EditorDescriptor is running but it doesn't change the property's appearance.

Am I missing something? Or isn't this possible, and why would it be possible to specify UiHint then?

Example property:

[Display(not relevant)]
[UIHint(SiteUiHints.WiderInput)]
public virtual string Title { get; set; }

UiHint:

public static class SiteUiHints
{
    public const string WiderInput = "WiderInput";
}

EditorDescriptor:

[EditorDescriptorRegistration(EditorDescriptorBehavior = EditorDescriptorBehavior.PlaceLast, TargetType = typeof(string), UIHint = SiteUiHints.WiderInput)]
public class WiderInputEditorDescriptor : EditorDescriptor
{
    public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable attributes)
    {
        base.ModifyMetadata(metadata, attributes);
        metadata.EditorConfiguration.Add("style", "width: 582px;");
    }
}
#145571
Mar 07, 2016 11:28
Vote:
 

I've found the solution.

The custom UiHint needs to be written in lowercase. 

In this case:

public static class SiteUiHints
{
  public const string WiderInput = "widerinput";
}

instead of "WiderInput"..

Thanks for rubber ducking though :)

#145572
Mar 07, 2016 11:51
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.