Submit does not include Kendo control value on the form data

1 Answer 179 Views
Form
Pedro
Top achievements
Rank 1
Pedro asked on 25 Oct 2022, 08:35 AM

If I have the following piece of code on a cshtml view

<div>
    @{ Html.BeginForm("test"); }
</div>
@Html.Kendo().NumericTextBox().Name("kendo")
<input name="native" type="text" />
<button type="submit">go</button>
@{ Html.EndForm(); }

When I submit the form, the native input value is on the form data, but not the kendo one.
If I remove the div around the BeginForm, it will submit.

Html.EditorFor controls also include their values on the form data, even on the case of incorrectly closed form tags.

Is this by design? If so, it should be documented as it is different than the native behavior.
If not, then it should be aligned with the native behavior.

Using Kendo.MVC 2022.3.913.545

1 Answer, 1 is accepted

Sort by
0
Yanislav
Telerik team
answered on 28 Oct 2022, 07:22 AM

Hello Pedro,

Thank you for the provided information and details. 

I've tested the behavior on my end and I've noticed that the rendered HTML form is not in the correct format. In general, the components are designed to work with a valid HTML structure, indeed in this case, it is strange that the native fields are sent, but the problem, in general, is that the structure of the rendered HTML document is invalid.

As you can see, the opening form tag is wrapped inside the div, which makes the document invalid and such unexpected behavior is actually expected. With that said, may I ask you what exactly you are trying to achieve, and is there a reason to structure the form this way? If you want to wrap the form inside a div element and include Telerik UI components along with native input fields, you can use a structure similar to the following one: 

<div>
    @{ using (Html.BeginForm("test2"))
        {
            @Html.Kendo().NumericTextBox().Name("kendo")
            <input name="native" type="text" />
            <button type="submit">go</button>
        }
    }
</div>

Thus, the rendered HTML will be valid and everything should be working as expected.

 

Regards,
Yanislav
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Pedro
Top achievements
Rank 1
commented on 28 Oct 2022, 08:26 AM

I know that the document is invalid, That's exactly what I've said. I'm just reporting that in older versions of Telerik it used to work, and so does native fields.
Yanislav
Telerik team
commented on 01 Nov 2022, 01:57 PM

Hello Pedro,

As I said in my previous reply, the components are designed and tested to work in a valid HTML structure. Even if they worked in an older version, they were not intended to be used in an invalid document. With that said, can I ask you what is the reason for using the components in an invalid HTML page and having an invalid structure in general? Also, may I ask you what you are trying to achieve as a final result, so I can further assist you?

Tags
Form
Asked by
Pedro
Top achievements
Rank 1
Answers by
Yanislav
Telerik team
Share this question
or