Write a program to Enable-Disable Textbox and change width of TextBox programmatically in Asp.Net.


Design:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server" Width="180px"></asp:TextBox>
        <br />
        <asp:Button ID="btnenable" runat="server" onclick="btnenable_Click" Text="Enable" />
        <asp:Button ID="btndisable" runat="server" onclick="btndisable_Click" Text="Disable" />
        <asp:Button ID="btnchange" runat="server" onclick="btndisable_Click" Text="ChangeWidth" />   
    </div>
    </form>
</body>
</html>

Code:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class textboxenable : System.Web.UI.Page
{
    protected void btnenable_Click(object sender, EventArgs e)
    {
        TextBox1.Enabled = true;
    }
    protected void btndisable_Click(object sender, EventArgs e)
    {
        TextBox1.Enabled = false;
    }
    protected void btnchange_Click(object sender, EventArgs e)
    {
        TextBox1.Width = Convert.ToInt32(TextBox1.Text);
    }
}

Popular posts from this blog

Write a program to check whether empty query string is entered in Asp.Net.

Mandavrayji Temple, Muli, Surendranagar, Gujarat

Write a program to change color of Label text control programmatically in Asp.Net.