Hello TS,
Sorry for my misunderstanding in my previous post. I reproduced this scenario and do more research about it. At last, I found some clues about it.
All web controls derive from WebControl class. In WebControl, it builds AddAttributesToRender method and defines Render method to be inherited by other child classes. In Render method of WebControl, it will call RenderBeginTag, RenderContents and RenderEndTag methods. protected internal override void Render(HtmlTextWriter writer) { this.RenderBeginTag(writer); this.RenderContents(writer); this.RenderEndTag(writer); }
In RenderBeginTag method, it will call AddAttributesToRender method which is defined in WebControl. But in CheckBoxList and RadioButtonList, render method is rewritten at all without touching RenderBeginTag method and AddAttributesToRender method. Hence, AddAttributesToRender as well as other methods which are called in Render method of WebCotnrol(contains RenderBeginTag , RenderContents and RenderEndTag methods) will not be triggered.
For OnPreRender method, it will be fired before Render method, so it is still available.
CheckBoxList will render a table with several items inside that is something like a composite control. By design, we needn't to define any attributes or styles for the entire object so that it can be like a collection of multiple CheckBox controls. With the table element participating, there are no BeginTag and EndTag needs to render. However, there is an additional method "RenderItem" that we can make use of to do something on the present item. Besides this, we can also use OnPreRender to add attributes on it.
If it's inappropriate to use OnPreRender in your case, please let me know. I will be happily work with you on further questions.