Jay,
Your problem is that you _have_ inherited the styles and properties of the base control. You then chose to ignore them in your Render override. The base control Render method knows what to do with the properties of the base control, but you don't call the base control Render method.
Take a look at the RenderItem method. The following worked in VS Web Developer Express Beta 1:
#region Using directives
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
#endregion
namespace JWS.WebInfrastructure.WebControls
{
public class MyRadioButtonList : RadioButtonList
{
public MyRadioButtonList()
{
}
protected override void RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)
{
if (itemType == ListItemType.Item ||
itemType == ListItemType.AlternatingItem ||
itemType == ListItemType.EditItem ||
itemType == ListItemType.SelectedItem)
{
writer.AddAttribute("onmouseover", "foo");
writer.AddAttribute("onmouseout", "bar");
ListItem item = Items[repeatIndex];
item.Attributes.AddAttributes(writer);
if (!item.Enabled)
writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "true");
if (item.Selected)
writer.AddAttribute(HtmlTextWriterAttribute.Checked, "true");
writer.AddAttribute(HtmlTextWriterAttribute.Value, item.Value);
writer.AddAttribute(HtmlTextWriterAttribute.Type, "radio");
writer.RenderBeginTag(HtmlTextWriterTag.Input);
writer.Write(item.Text);
writer.RenderEndTag();
return;
}
base.RenderItem(itemType, repeatIndex, repeatInfo, writer);
}
}
}
--
John Saunders
johnwsaundersiii at hotmail
No. I do call base.render. Base.render will display the original radiobuttonlist. The only way to add mouseover events to the individual options is to redo the render method entirely.
Jay
Are you calling base.Render when you're done with your code?
--
John Saunders
johnwsaundersiii at hotmail
I have subclassed RadioButtonList to add the mouseover and mouseout events to individual options. As far as I can see I have to totally rewrite the render method. The way I did it I have not included any inherited styles and properties. How do I inherit the styles and properties that have been set by the developer. I can add styles by using AddStyleAttribute. I can also determine what styles have been set using Me.style.keys and then add them using AddAtyleAttribute. Seems like there should be a way to add all at once all the styles that are inherited. Similarly, I cannot figure out how to add properties like Forecolor all at once.
I tried to override AddAttributesToRender but i do not seem to ever execute that method.
Help?
Jay