Hi nauna,
Check this example. Now please take its reference and correct your code.
HTML
<asp:Button ID="btnToggle" Text="Toggle" runat="server" OnClick="OnToggle" />
<hr />
<div id="dvDetails">
DV Details
</div>
<asp:HiddenField ID="hfDetails" runat="server" />
<script type="text/javascript">
function ShowHideDiv() {
var divDetails = document.getElementById('dvDetails');
var hfDetails = document.getElementById('hfDetails');
if (hfDetails.value == "1" || hfDetails.value == "") {
divDetails.style.display = "none";
hfDetails.value = "0";
} else {
divDetails.style.display = "block";
hfDetails.value = "1";
}
}
</script>
Code
C#
protected void OnToggle(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowHideDiv", "ShowHideDiv()", true);
}
VB.Net
Protected Sub OnToggle(ByVal sender As Object, ByVal e As EventArgs)
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "ShowHideDiv", "ShowHideDiv()", True)
End Sub
Screenshot