Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyRadioButtonList : RadioButtonList
- {
- private const string ScriptTemplate = "window.document.getElementById('{0}_{1}').checked = true;";
- protected override void OnPreRender(EventArgs e)
- {
- base.OnPreRender(e);
- if (!Page.IsPostBack)
- {
- for (int i = 0; i < Items.Count; i++)
- {
- if (Items[i].Selected)
- {
- Items[i].Selected = false;
- Page.ClientScript.RegisterStartupScript(typeof(RadioButtonList), string.Format("0}_DefaultValue", this.ClientID), string.Format(ScriptTemplate, this.ClientID, i), true);
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment