简体   繁体   中英

Radiobutton created dynamically rendered as unchecked in Chrome

I'm dynamically generating a radiobutton in code behind. And setting the checked property to true ie Checked = true for the radiobutton . on page_load the Radiobutton is rendered as checked in IE,Firefox but not in Chrome it does render as Radiobutton unchecked.

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?

I've tested and tested and I can't get Chrome to not have the radio button selected using the following code.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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