javascript - ASP.NET - preserve style of HTML element after postback -
javascript - ASP.NET - preserve style of HTML element after postback -
i had long break asp.net development.
i have div, toggled javascript function, on element's onclick
function.
<div id="insdetail" style="display: none">
after postback, div's state reverted collapsed. easiest way preserve style of div between postbacks? (viewstate maybe?)
you can utilize hidden field (control) , update state (e.g 1 = visible 0 = hidden) when alter visibility of div. next restore state in load page event.
more o less
aspx file:
<input runat="server" type="hidden" class="statediv" id='statediv' />
js file or in page:
$(function(){ var visibility = $(".statediv").val(); if(visibility== 1) $("#insdetail").show() else $("#insdetail").hide(); $(your_botton).click(function(){ //toggle div if ($("#insdetail").is(":visible")) $(".statediv").val(1); else $(".statediv").val(0); }); });
in way can command state server-side
javascript asp.net viewstate
Comments
Post a Comment