LinkButton lb = ((LinkButton)dgItem.FindControl(”lb”));
lb.Attributes[”onClick”] = ”return confirm(’Do you really want to do that?’);”;
I dont really know why the onClick confirm-box does not fire before the href PostBack. However, the solution was to put the LinkButton inside a span and put the onClick attribute on the span.
// Web page
<span runat="server" id="spanLb">
HtmlControl spanLb = ((HtmlControl)dgItem.FindControl(”spanLb”));
spanLb.Attributes[”onClick”] = ”return confirm(’Do you really want to do that?’);”;