ButtonEditFor

ButtonEdit is a text editor that allows you to display buttons within an edit box.

Implementation Details

ButtonEditFor is realized by the ButtonEditExtension class. Its instance can be accessed via the ButtonEditFor<ValueType>(Expression<Func<ModelType, ValueType>>) strongly typed helper method, which is used to add a ButtonEditFor extension to a view. This first method's parameter is an expression that identifies model property to display and edit. The second method's parameter provides access to the ButtonEditFor's settings implemented by the ButtonEditSettings class, allowing you to fully customize the extension.

The ButtonEditFor's client counterpart is represented by the ASPxClientButtonEdit object.

Declaration

ButtonEditFor can be added to a view in the following manner.

View code (Razor):

<script type="text/javascript">
    function FirstName_ButtonClick(s, e) {
        switch (e.buttonIndex) {
            case 0:
                s.SetText("");
                break;
            case 1:
                s.SetText("Some text");
                break;
        }
    }
</script>

@Html.DevExpress().ButtonEditFor(model => model.FirstName,
    settings => {
        settings.Name = "FirstName";

        settings.Text = "Some text";
        settings.Width = 200;
        settings.Properties.Buttons.Add("Clear");
        settings.Properties.Buttons.Add("Fill");
        settings.Properties.ClientSideEvents.ButtonClick = "FirstName_ButtonClick";
    }).GetHtml()

The code result is demonstrated in the image below.

buttonedit-declaration.png

See Also