I have this sample below:
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<script type="text/javascript">
function test(){
if (test.initialized=='undefined'){
test.initialized = 'true';
}
alert(test.initialized);
};
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:Button ID="btnPostBack" runat="server" Text="Post back" OnClientClick="test()" />
</asp:Content>
When I click post-back on the page, I found out that the variable initialized -which is defined on the function itself- is loosing its value and becoming ‘undefined’ again.
Is it possible to keep those static values once they are defined and make them unaffected from any post backs on the page?
You could add them as a query string or keep them in a cookie.