gpt4 book ai didi

c# - ASp.net Webform 多行文本框在页面加载时自动添加换行符

转载 作者:行者123 更新时间:2023-11-30 18:13:21 24 4
gpt4 key购买 nike

从过去一两周开始,我注意到我在基于 asp.net 网络表单的网站中使用的任何多行文本框都会自动向文本框添加换行符。

在我面对几乎所有 asp.net webform 网站都面临这个问题之前,这从未发生过

<textarea name="txtComment" rows="2" cols="20" id="txtComment" tabindex="4" class="comment-box">
</textarea>

enter image description here

我不确定为什么会这样。当我们更新页面时它会变得很糟糕&如果我们不手动删除换行符它将继续向多行文本框添加换行符。我不确定这个问题是由于某些 Windows 更新还是浏览器引起的。它发生在 Firefox 中,后来我在 Chrome 中发现了同样的情况?

不知道为什么会这样

例子:代码

    <asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine" Rows="3"> Line </asp:TextBox>
</div>
</form>

HTML 渲染输出

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>

</title></head>
<body>
<form method="post" action="./TESTMultiline.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNjQ0NTE4MDYwZGRecdSIl8wWZzLW33b1SXrfQmgMkA==" />
</div>

<div>
<input name="TextBox1" type="text" id="TextBox1" />

<textarea name="TextBox2" rows="3" cols="20" id="TextBox2">&#13;&#10; Line </textarea>
</div>

<div class="aspNetHidden">

<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="F8195D5B" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEdAAN9qVvxr9edjD9ICF1fyY9rESCFkFW/RuhzY1oLb/NUVB2nXP6dhZn6mKtmTGNHd3PbNvMJfATDdpnltdJAG8xg/EABZA==" />
</div></form>

<!-- Visual Studio Browser Link -->
<script type="application/json" id="__browserLink_initializationData">
{"appName":"Firefox","requestId":"b33e31c27a494a9c8d0d82b3f5432ca7"}
</script>
<script type="text/javascript" src="http://localhost:61571/7d590f801da8489ebffe28d952f8f4af/browserLink" async="async"></script>
<!-- End Browser Link -->

</body>
</html>

输出

enter image description here

最佳答案

问题与 TextBox 控件的呈现方式有关。在 web.config 中更改 controlRenderingCompatibilityVersion 的值对我有用:

controlRenderingCompatibilityVersion=4.5

信息来自问题Extra characters added to multiline textbox , 来自 JTapp/jmoreno 的回答。

关于c# - ASp.net Webform 多行文本框在页面加载时自动添加换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52814225/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com