Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Inheriting style and properties

Reply
Thread Tools

Inheriting style and properties

 
 
Jay
Guest
Posts: n/a
 
      07-26-2004
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


 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      07-26-2004
Are you calling base.Render when you're done with your code?

--
John Saunders
johnwsaundersiii at hotmail

"Jay" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
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


 
Reply With Quote
 
 
 
 
Jay
Guest
Posts: n/a
 
      07-26-2004
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
"John Saunders" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
Are you calling base.Render when you're done with your code?

--
John Saunders
johnwsaundersiii at hotmail

"Jay" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
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


 
Reply With Quote
 
John Saunders
Guest
Posts: n/a
 
      07-27-2004
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.Disabl ed, "true");
if (item.Selected)
writer.AddAttribute(HtmlTextWriterAttribute.Checke d, "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

"Jay" <(E-Mail Removed)> wrote in message news:%(E-Mail Removed)...
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
"John Saunders" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
Are you calling base.Render when you're done with your code?

--
John Saunders
johnwsaundersiii at hotmail

"Jay" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
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


 
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
Inheriting Data Properties Benjy Borda Javascript 12 07-17-2009 02:08 AM
Body not inheriting style from external CSS Lanmind HTML 12 09-08-2008 03:12 AM
"Inheriting" internal and external style sheets from window.opener relaxedrob@optushome.com.au Javascript 12 12-03-2004 11:23 PM
Need help with Style conversion from Style object to Style key/value collection. Ken Varn ASP .Net Building Controls 0 04-26-2004 07:06 PM
Problems with viewing inheriting Properties in VS.NET design time Dann Pool ASP .Net Web Controls 0 11-11-2003 07:11 PM



Advertisments