2017-11-15 3 views
-9

、クレジット/デビットradioButtonがチェックされたときに、これは私のaspx.csがテキストボックスが表示されない理由C#.netのCREDIT/DEBITラジオボタンをクリックするとどうなりますか?

protected void RadioButton1_CheckedChanged(object sender, EventArgs e) 
{ 
    TextBox2.Visible = true; 
} 

protected void Button1_Click(object sender, EventArgs e) 
{ 
    TextBox1.ReadOnly = false; 
} 

protected void RadioButton2_CheckedChanged(object sender, EventArgs e) 
{ 
    TextBox2.Visible = false; 
} 

を提出なぜテキストボックスが表示されないのですか?

+4

あなたはどんな問題に直面し、私はケースに知らせてください'?私たちは '.aspx'コードを見ることなくあなたを助けることはできません。 – BadMiscuit

+0

あなたのaspxコードも投稿してください –

答えて

0

AutoPostBack="true"を使用する必要があります。下記のコードを使用することができます。その作業

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> 

分離コードファイル

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; 
     } 
    } 
} 

"クレジットカード/デビット" `ラジオボタンは何

+0

ありがとうございます。うまくいきます – Dibya

関連する問題