简体   繁体   English

在Chrome中动态创建的单选按钮呈现为未选中状态

[英]Radiobutton created dynamically rendered as unchecked in Chrome

I'm dynamically generating a radiobutton in code behind. 我在后面的代码中动态生成一个radiobutton And setting the checked property to true ie Checked = true for the radiobutton . 并将checked属性设置为true,即radiobutton Checked = true on page_load the Radiobutton is rendered as checked in IE,Firefox but not in Chrome it does render as Radiobutton unchecked. 在page_load上,在IE,Firefox中, Radiobutton呈现为选中状态,但在Chrome中却未呈现,而是以Radiobutton未选中的形式呈现。

This is my code: 这是我的代码:

var radio = new HtmlInputRadioButton  
{  
ID = id  
};  
placeholder.Controls.Add(radio);  
radio.Name = name;  
radio.Checked = value;  

what is the fix to make the radiobutton selected on page_load for Chrome? 在Chrome的page_load中选择单选按钮的解决方法是什么?

I've tested and tested and I can't get Chrome to not have the radio button selected using the following code. 我已经测试过,并且无法使用以下代码让Chrome无法选择单选按钮。

var radio = new HtmlInputRadioButton
{
    ID = "testRadio",
    Name = "something",
    Checked = true,
};
phTest.Controls.Add(radio);

If you're still having problems you might post your actual code to demonstrate the issue. 如果仍然有问题,您可以发布实际代码来演示该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM