This is a migrated thread and some comments may be shown as answers.

[Solved] How to set the max length on ComboBox?

3 Answers 437 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Craig Fisher
Top achievements
Rank 1
Craig Fisher asked on 24 Jun 2011, 09:20 PM
I tried the following, but the maxLength attribute doesn't get set on the text input element:
.HtmlAttributes(new { maxLength = "80" })

Is this a bug? Or is there some other way of setting the maximum text length on the ComboBox?

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 27 Jun 2011, 07:51 AM
Hello Craig,

 
In order to achieve your goal, you will need to use InputHtmlAttributes instead of HtmlAttributes. HtmlAttributes will append attributes to the DIV wrapper instead of the input element.

Regards,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Craig Fisher
Top achievements
Rank 1
answered on 27 Jun 2011, 05:28 PM
That method doesn't exist on the ComboBoxBuilder in the Q1 2011 release.
0
Georgi Krustev
Telerik team
answered on 28 Jun 2011, 09:48 AM
Hello Craig,

 
InputHtmlAttributes method was introduced in the SP1 of Q1 2011 release of the Telerik extensions for ASP.NET MVC, which is available only for customers. 

As a workaround you can use client OnLoad event and set the maxLength attribute to the visible input element. Check this code snippet:

function onLoad() {
     $(this).data("tComboBox").$text.attr("maxlength", 80);
}
Regards,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ComboBox
Asked by
Craig Fisher
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Craig Fisher
Top achievements
Rank 1
Share this question
or