I have and ASP button and 2 Labels.
<asp:Button runat="server" ID="btnHide" />
<asp:Label runat="server" ID="lblName"></asp:Label>
<asp:Label runat="server" ID="lblPosition"></asp:Label>
I have created a dynamic JS script.
string jsbtnHide = @"document.getElementByID('" + lblName.ClientID + @"').value = '';
document.getElementByID('" + lblPosition.ClientID + @"').style.display = 'none';";
I assign the script to the button. I've tried both "OnClick" and "OnClientClick".
btnHide.Attributes.Add("OnClick", jsbtnHide);
However I cannot get the script to execute successfully and without a postback. I've tried adding OnClientClick="return false;" both dynamically and to the ascx file. Dynamically seems to be ignored, though it appears correct in FireBug. OnClick doesn't seem to prevent the Postback. When the script does run, lblName doesn't change to '', haven't got this to work once.
What am I doing wrong? I've been at this for days :(