如何在ASP.NET中自动调整GridView行中文本框的大小
我正在尝试在GridView行中添加数据绑定文本框:如何在ASP.NET中自动调整GridView行中文本框的大小,asp.net,Asp.net,我正在尝试在GridView行中添加数据绑定文本框: <ItemTemplate > <asp:TextBox ID="TextBox" runat="server" Visible="true" Enabled="true" Wrap="true" text='<%#Eval("Notes")%>' TextMode="MultiLine" > </asp:TextBox>
<ItemTemplate >
<asp:TextBox ID="TextBox" runat="server" Visible="true" Enabled="true"
Wrap="true" text='<%#Eval("Notes")%>' TextMode="MultiLine" >
</asp:TextBox>
</ItemTemplate>
我不知道如何使文本框自动调整为GridView行的高度如果您想知道多行文本框中内容的高度,您可以根据文本框的字体大小使用一个简单的公式。 在此处输入代码,例如数字不真实。 如果一行80个字符的宽度为400px,高度为20px,那么一行160个字符的宽度始终为400px,但高度为40px。 因此,在文本框的高度属性中,您可以编写 高度=
您也可以通过java脚本来完成
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Automatic Resize TextBox</title>
<script type="text/javascript">
function setHeight(txtdesc) {
txtdesc.style.height = txtdesc.scrollHeight + "px";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txtDesc" runat= "server" TextMode="MultiLine" onkeyup="setHeight(this);" onkeydown="setHeight(this);" />
</form>
</body>
</html>
谢谢很好!
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Automatic Resize TextBox</title>
<script type="text/javascript">
function setHeight(txtdesc) {
txtdesc.style.height = txtdesc.scrollHeight + "px";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txtDesc" runat= "server" TextMode="MultiLine" onkeyup="setHeight(this);" onkeydown="setHeight(this);" />
</form>
</body>
</html>