You have to use AutoPostBack="true"
and you can use the below code. Its working
Aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Stack_Overflow.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:RadioButton ID="RadioButton1" AutoPostBack="true" runat="server" Text="Credit" OnCheckedChanged="RadioButton1_CheckedChanged" GroupName="a">
</asp:RadioButton>
<asp:RadioButton ID="RadioButton2" AutoPostBack="true" runat="server" Text="Debit" OnCheckedChanged="RadioButton2_CheckedChanged" GroupName="a" />
<br />
<asp:Label ID="Label6" runat="server" Text="Label"></asp:Label>
<br />
<asp:Label ID="Label7" runat="server" Text="Label"></asp:Label>
<br />
<asp:Label ID="Label8" runat="server" Text="Label"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
code behind file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Stack_Overflow
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
Label6.Visible = true;
Label7.Visible = true;
Label8.Visible = true;
TextBox2.Visible = true;
TextBox3.Visible = true;
TextBox4.Visible = true;
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.ReadOnly = false;
}
protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
{
Label6.Visible = false;
Label7.Visible = false;
Label8.Visible = false;
TextBox2.Visible = false;
TextBox3.Visible = false;
TextBox4.Visible = false;
}
}
}
do let me know in case you face any issue
1
solved Why textbox is not appearing on Clicking the CREDIT/DEBIT radiobutton in C# .net? [closed]