[英]How can I set visible true for update Panel if Radio Button Checked?
I have 2 Radio Buttons, both of them should visible an update panel in the page but with different values for the tools in the panel. 我有2个单选按钮,它们都应该在页面中显示一个更新面板,但是面板中工具的值不同。 PS: I'm using a page depended on a master page on my website.
PS:我使用的页面取决于我网站上的母版页。 When I check any of radio buttons the panel doesn't visible!
当我检查任何一个单选按钮时,面板不可见!
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:";
}
}
It sounds like the GUI thread is busy. 听起来GUI线程很忙。 Try forcing the screen update by calling
Application.DoEvents()
, for example: 尝试通过调用
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()
will force all the message in the message queue to be processed. DoEvents()
将强制处理消息队列中的所有消息。
You will need to add values to your Radio Buttons like: "1" or "2" then you double click your RadioButton or RadioButtonList and this should appear in the .cs file: 您将需要向“单选按钮”中添加值,例如:“ 1”或“ 2”,然后双击您的RadioButton或RadioButtonList,这应显示在.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:";
}
}
So if one of then are selected, it will show the box with the Price Text in it. 因此,如果选择了其中一个,它将显示其中带有价格文本的框。 This can a better way to do what you want.
这可以做您想要的更好的方法。
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:";
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.