Skip to content

Razor pages - textarea asp-for binding problem #3193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
isaksky opened this issue Jun 4, 2018 · 1 comment
Closed

Razor pages - textarea asp-for binding problem #3193

isaksky opened this issue Jun 4, 2018 · 1 comment

Comments

@isaksky
Copy link

isaksky commented Jun 4, 2018

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:

public void OnPost() {
   // MyProperty = "Something"; // Updating this way does not work for `textarea`, but does for `input`

   // But this does:
   ModelState["MyProperty"].AttemptedValue = "My new value"`
}

Same as this issue, but this is for Razor Pages:

https://github.com/aspnet/Mvc/issues/6799

@pranavkm
Copy link
Contributor

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.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants