Thank you for your quick reply.
I thought of using an image button. But I would rather want a control wich you can give an path to the image and a text. Like:
<myComp:MyImageButton Id="imbtn" runat="server" ImageUrl="/pict.gif" Text="This is my button!" OnClick="MyBtn_Click"></myComp:MyImageButton>
and I want the whole component to be clickable.
Here i try implementing a click event to a label (the class derives from compositecontrol). The page does a post back, but I never got it to reach the Click function:
private Label label = new Label();
private string onClickFunction;
protected override void CreateChildControls()
{
label.ID = onClickFunction;
label.Attributes.Add("onclick", "javascript:__doPostBack('" + onClickFunction + "','');");
label.Text = "Click here.";
this.Controls.Add(label);
this.Controls.Add(new LiteralControl("<input type=\"hidden\" name=\"__EVENTTARGET\" id=\"__EVENTTARGET\" value=\"\" />"));
this.Controls.Add(new LiteralControl("<input type=\"hidden\" name=\"__EVENTARGUMENT\" id=\"__EVENTARGUMENT\" value=\"\" />"));
this.Controls.Add(new LiteralControl("<script>function __doPostBack(eventTarget, eventArgument)
{ var theForm = document.forms[0];if (!theForm.onsubmit || (theForm.onsubmit() != false))
{ alert(eventTarget);theForm.__EVENTTARGET.value = eventTarget;theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();};}</script>"));
}