多行文本框中的自动高度

发布于 2024-11-27 22:10:44 字数 240 浏览 2 评论 0原文

我必须使用多行文本框显示数据库中的数据。
如何在此多行文本框中设置自动高度?
我的代码在这里,

I have to show data from database with multiline textbox.
How can i set height auto in this multiline textbox?
My code is here,
<asp:TextBox ID="txtNaiyo" runat="server" TextMode="MultiLine" Rows="5" Width="100%" style="height:auto;" Value='<%# Eval("Naiyo") %>'/>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那请放手 2024-12-04 22:10:44

我做了一些很简单的事情。首先,我将 TextArea 放入 DIV 中。其次,我已调用此

<div id="divTable">
  <textarea ID="txt" Rows="1" TextMode="MultiLine" />
</div>

$(document).ready(function () {
  var heightTextArea = $('#txt').height();
  var divTable = document.getElementById('divTable');
  $('#txt').attr('rows', parseInt(parseInt(divTable .style.height) / parseInt(altoFila)));
});

Simple 脚本的 Ready Function。是div一次渲染的最大高度,除以一行的一个TextArea的高度。

I've made something quite easy. First I put the TextArea into a DIV. Second, I've called on Ready Function to this script

<div id="divTable">
  <textarea ID="txt" Rows="1" TextMode="MultiLine" />
</div>

$(document).ready(function () {
  var heightTextArea = $('#txt').height();
  var divTable = document.getElementById('divTable');
  $('#txt').attr('rows', parseInt(parseInt(divTable .style.height) / parseInt(altoFila)));
});

Simple. Is the Max Height of the div once is render, divided the height of one TextArea of one row.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文