简体   繁体   English

MVC2 C#TextAreaFor包含',,'

[英]MVC2 C# TextAreaFor contains ', ,'

I am using MVC2 C#. 我正在使用MVC2 C#。

I have the following issue: if the !ModelState.IsValid, I send the user back to the invalid form where my textareas contain ',' or duplicates whatever is in the textarea. 我有以下问题:如果是!ModelState.IsValid,我将用户发送回无效表单,其中我的textareas包含','或复制textarea中的任何内容。

<%=Html.TextAreaFor(x => x.Address, new { cols = 42, rows = 4 })%>
<%=Html.HiddenFor(x => x.Address)%> 

I pass this information inbetween forms, so I also have the value as a hidden at the bottom of the form, don't know another way of passing this information between forms (I have 8 forms in total which use 1 ViewModel). 我在表单之间传递了这些信息,所以我也有隐藏在表单底部的值,不知道在表单之间传递这种信息的另一种方式(我总共有8个表单,使用1个ViewModel)。

I know the hidden is causing the issue but don't know how to fix it. 我知道隐藏是导致问题,但不知道如何解决它。

Thanks in advance for any help 在此先感谢您的帮助

Clare 克莱尔

I had duplicated the values by having hidden fields on my aspx page. 我通过在我的aspx页面上隐藏字段来复制值。 Once removed the textareas no longer contained ', ,' when the page was refreshed. 删除后,当页面刷新时,textareas不再包含','。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM