razor pages, asp.net: retrieve value from bound textfield

Viewed 31

I created this formfield with a textbox at the bottom:

                        <div class="divFormField">
                            <table cellspacing="" cellpadding="0" border="0">
                                <tr>
                                    <td class="Label">
                                        <label for="position">Sprachen (INFO: Wenn nichts ausgewählt, automatisch "alle" (Wegen Backwardscomp.) Neue Tabelle mit einer Zeile pro Auswahl wenn spezifitiert.)</label>
                                    </td>
                                    <td class="Field">
                                        <table>
                                            @for (int i = 0; i < Model.Item.CheckedLanguages.Count; i++)
                                            {
                                                <tr>
                                                    <td>
                                                        @Html.HiddenFor(m => m.Item.CheckedLanguages[i].Name)
                                                        @Html.CheckBoxFor(m => m.Item.CheckedLanguages[i].isChecked)
                                                        <label>@Model.Item.CheckedLanguages[i].Name</label>
                                                        <div class="input-control text">
                                                            @Html.TextBoxFor(m => m.Item.CheckedLanguages[i].Test)
                                                        </div>
                                                    </td>
                                                </tr>
                                            }
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </div>

This is a child of this formfield:

<form action="@Url.Action("SaveEdit")" method="POST" id="idForm">
    @Html.HiddenFor(m => m.AutoCloseWindow)
    @Html.HiddenFor(m => m.Item.Id)

My Model is very simple:

public class CheckedLangs
{
    public string Name { get; set; }

    public string Test { get; set; }
    public int Id { get; set; }
    public bool isChecked { get; set; } = false;
}

I can see the input fields being rendered with the correct values I put onto my model beforehand. Now I just want to click save and retrieve the new entries on my model, but this is the result:

enter image description here

I did deffinatley put stuff into the textbox:

enter image description here

I just wrote "asd".

I was expecting to see "asd" being shown inside my variables now, but as you can see in the first picture, I am being returned null. (the default value). It is never overridden. I could put default values onto my model and they would show up here, but when I click save, the default values are still there and not what I typed into the input field.

Where am I missing the connection?

Thank you!

EDIT:

I have noticed that if my object is not from a list but say just a property, the binding works correclty...

0 Answers
Related