How to Enable Disable textbox programmatically in Asp.net C#

Source code

<!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 runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:TextBox ID="TextBox1" runat="server" Width="180px"></asp:TextBox>
        <br />
        <br />
        <asp:Button ID="btnenable" runat="server" onclick="btnenable_Click"
            Text="Enable" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Button ID="btndisable" runat="server" onclick="btndisable_Click"
            Text="Disable" />
   
    </div>
    </form>
</body>
</html>



Code Behind c# :-

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 Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnenable_Click(object sender, EventArgs e)
    {
        TextBox1.Enabled = true;
    }
    protected void btndisable_Click(object sender, EventArgs e)
    {
        TextBox1.Enabled = false;

    }
}


Out-Put:-

How to Enable Disable textbox programmatically in Asp.net C# How to Enable Disable textbox programmatically in Asp.net C# Reviewed by NEERAJ SRIVASTAVA on 11:31:00 PM Rating: 5

No comments:

Powered by Blogger.