Professional Web Applications Themes

Inheriting style and properties - ASP.NET Building Controls

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, ...

  1. #1

    Default Inheriting style and properties

    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


    Jay Guest

  2. #2

    Default Re: Inheriting style and properties

    Are you calling base.Render when you're done with your code?

    --
    John Saunders
    johnwsaundersiii at hotmail

    "Jay" <mesomewhere.com> wrote in message news:OUvNzNscEHA.1644tk2msftngp13.phx.gbl...
    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


    John Saunders Guest

  3. #3

    Default Re: Inheriting style and properties

    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" <johnwsaundersiiinotcoldmail.com> wrote in message news:evfWSQzcEHA.2164TK2MSFTNGP10.phx.gbl...
    Are you calling base.Render when you're done with your code?

    --
    John Saunders
    johnwsaundersiii at hotmail

    "Jay" <mesomewhere.com> wrote in message news:OUvNzNscEHA.1644tk2msftngp13.phx.gbl...
    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


    Jay Guest

  4. #4

    Default Re: Inheriting style and properties

    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" <mesomewhere.com> wrote in message news:%23TDYd21cEHA.1656TK2MSFTNGP09.phx.gbl...
    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" <johnwsaundersiiinotcoldmail.com> wrote in message news:evfWSQzcEHA.2164TK2MSFTNGP10.phx.gbl...
    Are you calling base.Render when you're done with your code?

    --
    John Saunders
    johnwsaundersiii at hotmail

    "Jay" <mesomewhere.com> wrote in message news:OUvNzNscEHA.1644tk2msftngp13.phx.gbl...
    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


    John Saunders Guest

Similar Threads

  1. Inheriting a control
    By Ant in forum ASP.NET Building Controls
    Replies: 1
    Last Post: July 24th, 04:10 AM
  2. inheriting Datagrid
    By King Kong in forum ASP.NET Building Controls
    Replies: 1
    Last Post: March 30th, 01:53 PM
  3. inheriting toolbar control
    By ???Q in forum ASP.NET Building Controls
    Replies: 0
    Last Post: September 13th, 08:02 AM
  4. Adding a font style to field properties
    By Mike_Pozsony@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 3
    Last Post: May 13th, 04:04 PM
  5. Replies: 0
    Last Post: April 26th, 07:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139