Extra characters added to multiline textbox

给你一囗甜甜゛ 提交于 2020-08-26 04:23:04

问题


The issue I am having is that when I create a multiline textbox, it prepends (carriage return line feed) characters.

I am using .NET 4.5. I created an empty project with just a multiline textbox:

<asp:TextBox ID="txtTest" runat="server" TextMode="MultiLine" Rows="5" Columns="50"></asp:TextBox>

In firefox and chrome it renders as:

<textarea name="txtTest" rows="5" cols="50" id="txtTest">&#13;&#10;</textarea> 

In IE, it is fine.

Thank you in advance.


回答1:


this is fixed in .NET 4.5 RTM version. Are you using 4. RC? Connect issue fixed in RTM




回答2:


Like jmoreno suggested, changing

controlRenderingCompatibilityVersion=4.0

to

controlRenderingCompatibilityVersion=4.5

in web.config helped me.




回答3:


The initial leading newline (LF or CRLF) of a textarea is ignored.

IE 8 and other older browsers (e.g. Firefox 3) remove the leading newline after parsing character entities.

However newer browsers removing the leading newline before parsing character entities, which then get interpreted as part of the default value of the textarea.

I don't know why .NET would generate those character entities.



来源:https://stackoverflow.com/questions/12827198/extra-characters-added-to-multiline-textbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!