Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Custom RadioButtonList with Attribute support for ListItem

Reply
Thread Tools

Custom RadioButtonList with Attribute support for ListItem

 
 
MattB
Guest
Posts: n/a
 
      07-22-2004
I found the listitem class was sealed,

and can't get tooltips for radio button in
a radionbuttonlist, apparently this is by design..

http://support.microsoft.com/default...;en-us;Q309338

no one said why, I would just write a bunch of radiobutton controls
but I have I have a Checklist validator

http://www.dotnetjunkies.com/Article...B5D641D20.dcik

and want to continue using it, as I am not sure how to get a group of
radiobuttons of Checkboxes in to verify one of them is select

so I wrote the following, all is good except I lose the viewstate of
the
selected radiobutton on postback, I am new to custom controls and they
seem
very dependant on what which class you are overriding....

can anyone help, thanks...m@

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MY.UI
{
/// <summary>
/// Summary description for TooltipRadioButtonList.
/// </summary>
public class TooltipRadioButtonList :
System.Web.UI.WebControls.RadioButtonList
{
protected override void Render(HtmlTextWriter writer)
{
//RenderChildren(writer);
int i = 0;
foreach (ListItem listItem in Items)
{
writer.WriteBeginTag("input");
writer.WriteAttribute("ID",this.UniqueID+"_"+i );
writer.WriteAttribute("type", "radio");
writer.WriteAttribute("name", this.UniqueID);
writer.WriteAttribute("value", listItem.Value, true);
listItem.Attributes.Render(writer);
writer.Write('>');
writer.WriteEndTag("input");
writer.WriteBeginTag("label");
writer.WriteAttribute("for",this.UniqueID+"_"+i );
listItem.Attributes.Render(writer);
writer.Write('>');
HttpUtility.HtmlEncode(listItem.Text, writer);
writer.WriteEndTag("label");
if (i < Items.Count-1)
writer.RenderBeginTag(HtmlTextWriterTag.Br);
writer.WriteLine();
i++;
}
}
}
}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
attribute or is not a valid attribute od element ListItem Dan ASP .Net 2 08-02-2008 09:28 PM
<asp:ListItem Value="0">blank choice</asp:ListItem> ? Jim in Arizona ASP .Net 7 11-22-2006 08:31 AM
how do I add an custom attribute to a listitem inside a dynamically created listbox? Rick Spiewak ASP .Net 3 12-23-2004 09:35 PM
Custom RadioButtonList with Attribute support for ListItem MattB ASP .Net Building Controls 0 07-23-2004 10:52 PM
ropdownlist listitem.value not working - returns listitem.text instead Mad Scientist Jr ASP .Net 2 06-29-2004 01:13 PM



Advertisments