Saturday, 3 August 2013

Auto Resize Text Area

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="AutometicResizetextBox.aspx.cs" Inherits="_AutometicResizetextBox" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<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" style="resize:none" onkeyup="setHeight(this);" onkeydown="setHeight(this);" />
</form>
</body>
</html>

No comments:

Post a Comment