在多行文本框自动高度 [英] auto height in multiline textbox

查看:445
本文介绍了在多行文本框自动高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须展示从多行文本数据库中的数据。结果
如何设置自动高度在这个多行文本?结果
我的code是在这里,

< ASP:文本框ID =txtNaiyo=服务器的TextMode =多行行=5WIDTH =100%的风格=高度:汽车;值='<%#的eval(Naiyo)%>/>

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") %>'/>

推荐答案

我做的东西很容易。首先,我把文本区成DIV。其次,我已经呼吁准备功能,以这个剧本

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)));
});

简单。是div的最大高度一旦呈现,分为一排的一个文本区域的高度。

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

这篇关于在多行文本框自动高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆