I'm experiencing some weird behaviour when using a ASP.NET LinkButton with a 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-behind
protected void Page_Load(object sender, EventArgs e)
{
btnDeleteGroup.OnClientClick = "return confirmAction('delete?');";
}
Without the OnClientClick, everything is fine. With the OnClientClick, my LinkButton dissappears when a postback occurs (using the DropDownList).
In another topic, I've found a solution to set EnableViewState to false. But the application I'm writing is multilingual so with EnableViewState set to "false", I'm also losing my translation.
if ( !Page.IsPostBack ) {
// translate all form elements
TranslationUI();
}
I rather not call this method outside the !Page.IsPostBack method because the TranslationUI-method() translates the form elements based on a database.
<a>tag for the link button does not contain any nested tags any longer. This is why it looks like it disappears..