-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Textarea tagHelper is not rendering the contents of the element correctly. #4852
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
Comments
If I understood this correctly, this is currently by design, though I confess I easily see why it's confusing. ModelState (which is part of ViewData) always overrides model values because it represents the "in progress" value of the field. For example, if a user typed |
We think we might be able to build some APIs that make this easier, but they would have discoverability problems. For example, we could add some APIs that let you do things like: ModelState.UpdateValue("SomeProperty", newValue);
or
ModelState.UpdateValue<MyModel>(m => m.SomeProperty, newValue); What these end up doing is quite simple (though admittedly also difficult to discover), which is set For the reasons mentioned above, moving this to Backlog. |
Appreciate your response @Eilon and apologies for not responding sooner. It's subtle, but I understand. For now, I can just use the Thanks for the clarification.
Since this is probably not a common scenario and the workround is fine, it should probably be closed. |
@colhountech thanks for responding! We'll leave this open for at least a while to see if demand for this spikes - we often close Backlog items if they're largely untouched over at least a few months. |
@Eilon, For reference, in case anyone else has the same issue, I've update the demo to show what I was trying to do, and what I needed to change in order to update the See here. https://github.com/colhountech/TextAreaDemo/blob/master/README.md |
I have the same problem. Simple model on a cshtml page (without the @page at the top), the text is rendered into an input tag helper but not in the text area.
On the same page the input works, the text area not. |
I'm getting the same issue as @francescocristallo . The |
The following |
I don't often work with Razor, but there seem to be a rather misleading promise re: bound properties. If a bound property is modified on a GET, then the new value are showing on screen. However, if a bound property is modified in a POST handler, the new value does NOT make it to screen, regardless of whether the type of control is a textarea or an input box (or other). The solution is to clear the model state, before returning from the post handler. |
Hi. Thanks for contacting us. |
The
<textarea>
tag helper is not rendering the content of the element correctly for a Razor Page.If a Model property called
Messages
is modified in the OnPost, this update is visible in the view by using the razor directive@Model.Messages
, but the<textarea>
element does not display the correct innerHtml content.This issue has been previously raised and closed because it could not be replicated.
aspnet/Mvc#3964
This example reproduces the issue:
https://github.com/colhountech/TextAreaDemo
Here is my attempt that fixes the scenario. I have not looked at regression so don't know yet if it
affects any other tests.
https://github.com/colhountech/Mvc/pull/1/files
basically it comes down to the following code segment in the
The issue seems to be related to both the
ViewData
and themodelExplorer
returning a valid value, however themodelExplorer
has the correct value, and this condition is never satisfied because the preceding condition is always true.My fix for this issue is to remove the else, and allow the
Model
to take precedence over theViewData
( I'm not sure if this effects regression), as follows:Hope this is an accurate understanding of the issue, if not please feel free to close.
The text was updated successfully, but these errors were encountered: