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

[Solved] clear text and value

1 Answer 201 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.
JULIA
Top achievements
Rank 1
JULIA asked on 07 Sep 2010, 09:27 AM
Hello,

i have the following dropdownlist
<%= Html.Telerik().DropDownListFor( d => d.SelectedAtcCode ).HtmlAttributes( new { style = "width: 250px;" } ) %>
[Required]
public string SelectedAtcCode { get; set; }

The DropDownLost will be filled with Ajax:

function agentChanged(e) {
    var atcList = $('#Agent_SelectedAtcCode').data('tDropDownList');
    getData('<%= Url.Content("~/Controller/Action") %>', { agent: e.value }, atcList);
}
  
function getData(url, params, ctrl) {
    $.getJSON(url, params, function (data) {
        if (data.Data) {
            ctrl.dataBind(data.Data);
            ctrl.text(""); // ctrl.text(null);
            ctrl.value(""); // ctrl.value(null);
            ctrl.open();
        }
    });
}

I select an item and reload the data. the code in getdata runs again and i select no item. on submit the SelectedAtcCode is set on the value before and the required validator will not run.
how can i reset the value, so that the validator will run?

Regards,
Timo

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 07 Sep 2010, 11:50 AM
Hello Timo,

This is expected behavior, because DropDownList always has selected item. This is by design. Select HTML element works in the same way.

In order to achieve your goal, I will suggest you use ComboBox UI component.

Best wishes,
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
JULIA
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or