New to Telerik UI for ASP.NET MVC? Download free 30-day trial

Floating Label

A floating label is a placeholder text for form or input fields, which floats above that field and remains visible once the user starts interacting with that field.

To implement a floating label in the Telerik UI AutoComplete for ASP.NET MVC, define it either as a string or from a function handler.

The following example demonstrates how to set the floating label as a string:

        @(Html.Kendo().AutoComplete()
            .Name("products")
            .DataTextField("ProductName")
            .Filter("contains")
            .Label(label => {
                label.Content("Find a product...");
                label.Floating(true);
            })
            .HtmlAttributes(new { style = "width:100%" })
            .DataSource(source =>
            {
                source.Read(read =>
                {
                    read.Action("FloatingLabel_GetProducts", "AutoComplete");
                });
            })
         )

The following example demonstrates how to set the floating label from a function handler:

        @(Html.Kendo().AutoComplete()
            .Name("products")
            .DataTextField("ProductName")
            .Filter("contains")
            .Label(label => {
                label.ContentHandler("contentHandler");
                label.Floating(true);
            })
            .HtmlAttributes(new { style = "width:100%" })
            .DataSource(source =>
            {
                source.Read(read =>
                {
                    read.Action("FloatingLabel_GetProducts", "AutoComplete");
                });
            })
        )

        <script>
            function contentHandler(){
                return "Find a product...";
            }
        </script>

See Also

In this article