Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling a postback of a dynamic imageButton

Tags:

c#

asp.net

I have a table in an update panel. This table gets filled form the code behind and there is also a button added. This button triggers a Javascript. Because this button triggers a Javascript I don't need the button to do a postback. Is there a way to disable this postback?

This is the code I use to set the imagebutton in a table cell for each row.

ImageButton ibtnTableOneNewComment = new ImageButton();
ibtnTableOneNewComment.ImageUrl = "~/img/Pencil.png";
ibtnTableOneNewComment.OnClientClick = "setDiscription('test', 'testy')";           
tabCell.Controls.Add(ibtnTableOneNewComment);

The table headers get set in the asp, the rest from the code behind.

<asp:UpdatePanel runat="server" ID="up_tableMain" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Table runat="server" ID="tbl_main">
          ...Headers...
        </asp:Table>
    </ContentTemplate>
</asp:UpdatePanel>
like image 559
Freddy Avatar asked Dec 31 '25 13:12

Freddy


1 Answers

Put return false; in your OnClientClick

like image 98
MikeLim Avatar answered Jan 02 '26 03:01

MikeLim