I am experiencing some strange behavior when using ASP.NET LinkButton with the OnClientClick property.
Aspx
<asp:DropDownList ID="test" runat="server" AutoPostBack="true"> <asp:ListItem>test1</asp:ListItem> <asp:ListItem>test2</asp:ListItem> <asp:ListItem>test3</asp:ListItem> </asp:DropDownList> <asp:LinkButton CssClass="button" ID="btnDeleteGroup" runat="server"> <img src="cross.png" alt="delete-group" width="16" height="16" /> <span><asp:Literal ID="lblDeleteGroup" runat="server" Text="Delete" /></span> </asp:LinkButton>
Code for
protected void Page_Load(object sender, EventArgs e) { btnDeleteGroup.OnClientClick = "return confirmAction('delete?');"; }
Without OnClientClick, everything is fine. With OnClientClick, my LinkButton disappears when postback occurs (using DropDownList).
In another topic , I found a solution to set EnableViewState to false. But the application I'm writing is multilingual, so with EnableViewState set to false, I also lose the translation.
if ( !Page.IsPostBack ) {
I prefer not to call this method outside the method! Page.IsPostBack because TranslationUI-method () converts form elements based on the database.
source share