If you want to achieve this functionality using JavaScript, the recommended approach is to remove the OnClick attribute from the LinkButton and utilize the OnClientClick attribute to invoke a JavaScript function instead:
<asp:LinkButton ID="lb_link_button" runat="server" Text="Click Me" OnClientClick="return ToggleShowHide()"/>
Below is an example of a JavaScript function that can show/hide a control named my_control by manipulating its style.display property:
<script type="text/javascript">
function ToggleShowHide() {
var control = document.getElementById("<%= my_control.ClientID %>");
if (control.style.display == "none") { control.style.display = "block"; }
else { control.style.display = "none"; }
return false;
}
</script>
There are various ways to reference the controls for showing/hiding, and this is just a simple illustration.
It's important to note that the controls intended to be set as visible/invisible should not have their Visible property explicitly set to false. Instead, they should be initially declared with a style of display:none; like so:
<asp:Control runat="server" ID="my_control" Visible="true" style="display:none;"/>