Combobox in beginform submitting two querystring values

2 posts, 0 answers
  1. daniel
    daniel avatar
    1 posts
    Member since:
    Feb 2011

    Posted 15 Sep 2015 Link to this post


    We have a combobox and a button inside a form (all HTML helper) and when we submit (its just a search form) two querystring items are appended to the forms destination - one with the name of the "Combobox" giving the value and one with "ComboBox_input" giving the text.

    We're using a combobox so we can have the Text and the Value separate.

    How can we stop both the Text AND Value being added as a querystring value?

    I know we can do an on change event and window.location, but we've a requirement for an actual button to click and I thought this would work ...

    01.@using (Html.BeginForm("Details", "Property", FormMethod.Get))
    02.    {
    04.    @(Html.Kendo().ComboBox()
    05.    .Name("PropertyId")
    06.    .DataTextField("Searchable")
    07.    .DataValueField("PropertyRef")
    08.    .Placeholder("Search for property by ref or name ...")
    09.    .Filter(FilterType.Contains)
    10.    .AutoBind(false)
    11.    .MinLength(4)
    12.    .DataSource(source =>
    13.    {
    14.        source.Read(read =>
    15.        {
    16.            read.Action("PropertySearch_Read", "Search");           
    17.        })
    18.    .ServerFiltering(false);
    19.    })
    20.   .HtmlAttributes(new { style = "width:100%" })
    21.    )
    24.    @(Html.Kendo().Button()
    25.        .Name("btnSubmit")
    26.        .HtmlAttributes(new { type = "submit" })
    27.        .Content("Search")
    28.    )



  2. Georgi Krustev
    Georgi Krustev avatar
    3724 posts

    Posted 17 Sep 2015 Link to this post

    Hello Daniel,

    The ComboBox widget is designed to add name attribute to the visible input element. This is required by some server frameworks (ASP.NET MVC for instance) to return the posted value when the model is not valid.

    If you would like to prevent this behavior, then you can remove the name attribute from the element using JavaScript:
    <!-- widget declaration -->
      $(function() {

    Georgi Krustev
    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 Feedback Portal and vote to affect the priority of the items
Back to Top