C# 如果选中单选按钮,如何为更新面板设置visible true?
我有两个单选按钮,它们都应该在页面中的更新面板中可见,但面板中的工具值不同。 附言:我使用的网页依赖于我网站上的母版页。 当我检查任何单选按钮时,面板不可见C# 如果选中单选按钮,如何为更新面板设置visible true?,c#,jquery,html,asp.net,C#,Jquery,Html,Asp.net,我有两个单选按钮,它们都应该在页面中的更新面板中可见,但面板中的工具值不同。 附言:我使用的网页依赖于我网站上的母版页。 当我检查任何单选按钮时,面板不可见 protected void Sale_CheckedChanged(object sender, EventArgs e) { if (Sale.Checked) { UpdatePanel1.Visible = true; PriceLabel.Text = " Sale Price:"
protected void Sale_CheckedChanged(object sender, EventArgs e)
{
if (Sale.Checked)
{
UpdatePanel1.Visible = true;
PriceLabel.Text = " Sale Price:";
}
}
protected void Rent_CheckedChanged(object sender, EventArgs e)
{
if (Rent.Checked)
{
UpdatePanel1.Visible=true;
PriceLabel.Text = " Rent Price:";
}
}
听起来GUI线程很忙。尝试通过调用
Application.DoEvents()
强制屏幕更新,例如:
protected void Sale_CheckedChanged(object sender, EventArgs e)
{
if (Sale.Checked)
{
UpdatePanel1.Visible = true;
PriceLabel.Text = " Sale Price:";
Application.DoEvents();
}
}
protected void Rent_CheckedChanged(object sender, EventArgs e)
{
if (Rent.Checked)
{
UpdatePanel1.Visible=true;
PriceLabel.Text = " Rent Price:";
Application.DoEvents();
}
}
DoEvents()
将强制处理消息队列中的所有消息。您需要向单选按钮添加值,如:“1”或“2”,然后双击您的RadioButton或RadioButton列表,该值应显示在.cs文件中:
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (RadioButtonList1.SelectedValue == 1)
{
UpdatePanel1.Visible = true;
PriceLabel.Text = "Text1:";
}
else
{
UpdatePanel2.Visible = true;
PriceLabel.Text = "Text2:";
}
}
因此,如果选择其中一个,它将显示包含价格文本的框。
这可能是一种更好的方法来完成您想要的任务。您是否有任何代码使UpdatePanel1不可见?另外,PriceLabel文本是否被更改?实际上,我已使UpdatePanal1在设计中不可见。我是否应该使用任何名称空间来使用它?因为当我按下按钮时,DoEvents不会出现。!它不工作,同样的问题,当我选择单选按钮时,事件不适用!
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Checked == true)
{
UpdatePanel1.Visible = true;
PriceLabel.Text = " Sale Price:";
}
else
{
UpdatePanel1.Visible = true;
PriceLabel.Text = " Rent Price:";
}
}