programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Website by URL, How to Play YouTube Videos in by using Jquery , Jquery Change div background on mouseover in , JQuery UI Datepicker (Calendar) etc.

Friday, November 28, 2014 Auto re-size textbox control

Resize multiline textbox automatically when we Enter text: MultiLine textbox:

In this post we want to create a simple Example of text box control. When we enter data in this text box control we want to the length (re-size height and width) of text box. In this tutorial we give many example related to text box as like Limitation of Characters in Textbox  , Displaying the textbox value in javascript Messagebox , How to use alert and display textbox value by javascript , Introduction of ASP.NET Server Control Basics , jquery disable or Enable submit button after Textbox validation etc.

We take a Example here in this we consider a text box and try to Auto re-size it when we enter value in text box.

JavaScript function for resize control:

Text box auto resize function.

function resizemultilineTextBox(txt) {
   = "1px";
   = (1 + txt.scrollHeight) + "px";
        } web page code with Textbox:

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head id="Head1" runat="server">
        function resizemultilineTextBox(txt) {
   = "1px";
   = (1 + txt.scrollHeight) + "px";
    <style type="text/css">
            color: #990000;
            text-decoration: underline;
            font-family: Arial, Helvetica, sans-serif;
    <form id="form2" runat="server">
        <div align="center" style="height: 123px; background-color: #6699FF">
        <h1 class="style1">Auto Resize TextBox Control</h1>
            <table style="width: 494px">
                    <td>Enter Text Here: </td>
                        <asp:TextBox ID="txtDescription" runat="server"
                            onkeyup="resizemultilineTextBox(this)" TextMode="MultiLine" Width="212px"></asp:TextBox>
</html> web server control Post :

No comments:

Post a Comment