You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For razor pages, when one modifies a bound model property in an OnPost method on a page with a asp-for="MyProperty" property, the new value is shown for input controls, but not for textarea controls. For textarea, when the page is rendered, it stays the same as the AttemptedValue.
To be clear:
<input asp-for="MyProperty"> shows the new value when it is updated in OnPost, but <textarea asp-for="MyProperty"></textarea> does not.
I would expect that the behavior (whether asp-for is bidirectional) should be consistent across input types, like input, textarea, select, etc.
Workaround:
publicvoidOnPost(){// MyProperty = "Something"; // Updating this way does not work for `textarea`, but does for `input`// But this does:ModelState["MyProperty"].AttemptedValue="My new value"`
}
The linked issue is also for Razor Pages. That said, both Razor Views and Razor Pages have the same underlying infrastructure, the behavior and the possible fix would be the same. Closing this and since the other item is already tracking further work.
For razor pages, when one modifies a bound model property in an
OnPost
method on a page with aasp-for="MyProperty"
property, the new value is shown forinput
controls, but not fortextarea
controls. Fortextarea
, when the page is rendered, it stays the same as theAttemptedValue
.To be clear:
<input asp-for="MyProperty">
shows the new value when it is updated inOnPost
, but<textarea asp-for="MyProperty"></textarea>
does not.I would expect that the behavior (whether
asp-for
is bidirectional) should be consistent across input types, likeinput
,textarea
,select
, etc.Workaround:
Same as this issue, but this is for Razor Pages:
https://github.com/aspnet/Mvc/issues/6799
The text was updated successfully, but these errors were encountered: