P
Peter Colson
I've successfully made a custom control based on an image
button and prevented it from doing postbacks by
overriding Render and providing a doClick script function
(built in OnPreRender) that returns false, as follows:
protected override void Render(HtmlTextWriter writer)
{
writer.WriteBeginTag("input");
writer.WriteAttribute("type", "image");
writer.WriteAttribute("name", UniqueID);
if (ID != null)
writer.WriteAttribute("id", ClientID);
writer.WriteAttribute("src", ImageUrl);
// Override click event and prevent postback.
writer.WriteAttribute("OnClick", "javascript:return
doClick()");
writer.Write(HtmlTextWriter.TagRightChar);
} // Render
Problem is: this has completely taken over the rendering
of the ImageButton rather than allowing the base class to
render itself.
I thought something like:
base.Render(writer);
Attributes.Add("OnClick", "javascript...etc");
may have worked, but to no avail.
Any thoughts?
button and prevented it from doing postbacks by
overriding Render and providing a doClick script function
(built in OnPreRender) that returns false, as follows:
protected override void Render(HtmlTextWriter writer)
{
writer.WriteBeginTag("input");
writer.WriteAttribute("type", "image");
writer.WriteAttribute("name", UniqueID);
if (ID != null)
writer.WriteAttribute("id", ClientID);
writer.WriteAttribute("src", ImageUrl);
// Override click event and prevent postback.
writer.WriteAttribute("OnClick", "javascript:return
doClick()");
writer.Write(HtmlTextWriter.TagRightChar);
} // Render
Problem is: this has completely taken over the rendering
of the ImageButton rather than allowing the base class to
render itself.
I thought something like:
base.Render(writer);
Attributes.Add("OnClick", "javascript...etc");
may have worked, but to no avail.
Any thoughts?