PreRender event not firing on ImageButton

D

DalePres

Does anyone know if there is a known bug or workaround, or other solution to
this problem?

I have a page with several imagebutton server controls and needed to
handle the PreRender event in C#. In all my tests, on several pages and
circumstances, the Init and PreRender events never fire for the image
button.

If I add a regular button server control, or several regular button server
controls, and the PreRender and Init events fire as expected for the regular
button controls.

Dale
 
N

Natty Gur

Hi,

It's a known bug.

if you want to workaround it create new custom control derived from
ImageButton. override the onPreRender method. I add a sample control
code :

public class MyImageButton : ImageButton
{
public new event EventHandler PreRender;
public MyImageButton() : base()
{
//
// TODO: Add constructor logic here
//

}
protected override void OnPreRender(EventArgs e)
{
PreRender(this,e);
this.ToolTip = "Render";
base.OnPreRender(e);
}


}

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top