I have a simple form:
<form method="post" enctype="multipart/form-data" asp-page-handler="Button_Submit">
<input value="@Model.yolonese.test" name="hi" />
<input style="width: 30% !important; opacity: 0.2; " value="Weiter" class="baseButton" type="submit">
</form>
a page model:
public class Skills : PageModel
{
public Yolonese yolonese { get; set; }
public Skills()
{
}
public void OnGet()
{
yolonese = new Yolonese();
}
public void OnPost(Yolonese model)
{
}
}
and a model:
public class Yolonese
{
public string test { get; set; } = "test";
}
When my page is rendered, the input value displays "test". When I alter the value and check for what is posted, "test" is returned. Irregardless of what I wrote into the input.
Why is that?
The issue is, you cannot bind to an input the way I did, best to use this:
@Html.TextBoxFor(m => m.test)
then the values simply written on the model without the need of an extra controller