1: public class RadioButtonListPlus : RadioButtonList
2: { 3: protected override void Render(HtmlTextWriter writer)
4: { 5: ListItemCollection items = this.Items;
6: if (items.Count > 0)
7: { 8: for (int i=0; i<items.Count; i++)
9: { 10: ListItem item = items[i];
11: //Creazione del tag span
12: writer.WriteBeginTag("span"); 13: AttributeCollection attrs = item.Attributes;
14: foreach (string key in attrs.Keys)
15: //Add dello stile
16: writer.WriteAttribute( key, attrs[key]);
17: writer.Write( ">");
18: //Creazione del controllo radio
19: writer.WriteBeginTag("input"); 20: writer.WriteAttribute( "id", this.ClientID + "_" + i.ToString());
21: writer.WriteAttribute("type", "radio"); 22: writer.WriteAttribute("name", this.UniqueID); 23: writer.WriteAttribute("value", item.Value); 24: if( item.Selected)
25: writer.WriteAttribute("checked", "checked"); 26: if( this.AutoPostBack)
27: { 28: RadioButton rb = new RadioButton();
29: rb.ID = this.ClientID + "_" + i.ToString();
30: writer.WriteAttribute( "onclick", Page.GetPostBackClientEvent( rb, string.Empty));
31: }
32: writer.Write( ">");
33: //Creazione del controllo label contenente il testo da visualizzare accanto al RadioButton
34: if( item.Text.Length > 0)
35: { 36: writer.Write( "<label");
37: writer.WriteAttribute( "for", this.ClientID + "_" + i.ToString());
38: writer.Write( ">");
39: writer.Write( item.Text);
40: writer.WriteEndTag( "label");
41: }
42: writer.WriteEndTag("input"); 43: writer.WriteEndTag("span"); 44: }
45: }
46: }
47: }