I have got this code:
public partial class Default2 : System.Web.UI.Page
{
public bool MyProperty { get; set; }
Button newBTN;
GenerateMe gm;
protected void Page_Load(object sender, EventArgs e)
{
newBTN = new Button();
newBTN.Text = "Button 1";
gm = new GenerateMe(PlaceHolder1, newBTN);
gm.ExecuteAll();
Response.Write(gm.ResponseWrite());
}
}
class GenerateMe
{
PlaceHolder holder;
Button button;
RadioButton b = new RadioButton();
string buttonPressed;
public GenerateMe(PlaceHolder h, Button b)
{
holder = h;
button = b;
}
public void ExecuteAll()
{
Table t = new Table();
TableRow tr = new TableRow();
TableCell tc = new TableCell();
tc.Controls.Add(button);
tr.Cells.Add(tc);
t.Rows.Add(tr);
holder.Controls.Add(t);
holder.Controls.Add(b);
if (b.Checked)//This is always false
{
buttonPressed = b.Checked.ToString();
}
}
public string ResponseWrite()
{
return buttonPressed;
}
}
ラジオボックスがチェックされていることがわかります。しかし、チェックされたプロパティはポストバック間で常にfalseです。それが押された場合、ラジオボックスの状態を取得するにはどうすればいいですか。ポストバック間でのラジオボックス状態の取得
ps。私はradioboxesイベントを使用したくない。ポストバック後に押された場合、プロパティを取得したい。
コード内のCheckBoxはどこにありますか?ラジオボタンについて話していますか? – Illuminati
申し訳ありませんラジオボックスです...前にチェックボックスを使用しました..私はそれを変更しました –
ラジオボタンのステータスを確認するのはいつですか?コードでコメントなどを指定します。 – Illuminati