Practical : 19
Subject : .Net
Aim : Write a program to Enable-Disable Textbox and change width of Textbox programmatically in Asp.Net.
Source Code :
//file.aspx
<%@ Page Language="C#"
AutoEventWireup="true" CodeBehind="pra19.aspx.cs"
Inherits="dotnet008asp.pra19" %>
<%@ Register assembly="AjaxControlToolkit"
namespace="AjaxControlToolkit" tagprefix="ajaxToolkit"
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>pratik008</title>
</head>
<body>
<form
id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"
placeholder="mobile no"
OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
</div>
<p>
<asp:Label
ID="Label1" runat="server"
Text="or"></asp:Label>
</p>
<p>
<asp:TextBox ID="TextBox2" runat="server"
placeholder="Email" width=”200px” OnTextChanged="TextBox2_TextChanged"></asp:TextBox>
</p>
<p>
<asp:Button ID="Button1" runat="server"
Text="Button" />
</p>
</form>
</body>
</html>
//file.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace dotnet008asp
{
public partial
class pra19 : System.Web.UI.Page
{
protected void
TextBox1_TextChanged(object sender, EventArgs e)
{
TextBox2.Enabled = false;
TextBox1.Enabled = true;
TextBox2.Text = "Disabled";
}
protected void
TextBox2_TextChanged(object sender, EventArgs e)
{
TextBox1.Enabled = false;
TextBox2.Enabled = true;
TextBox1.Text = "Disabled";
}
}
}
Output :
0 comments:
Post a Comment