My current setup involves a simple div with the display set to none. Upon page load, I use $("#MyDiv").show(); to display the div after a delay, allowing users to enter information into the form and submit it using an asp.net button.
After submitting the form and reloading the page, the JavaScript function runs again, causing the div to reappear. How can I disable this function after postback?
I am aware that you can use the following code:
if (Page.IsPostBack){}
However, I am unsure of how to actually disable the function. Here is how my function currently looks:
function testpopup() {
setTimeout(function () { $("#MyDiv").show(); }, 1500);
};
Any suggestions on how to achieve this? Thank you.
Update: I have found a solution by setting a hidden input field with the value of "N" like this:
<input type="hidden" id="IsFormSubmitted" value="N" runat="server" />
Then I modified the function to check and update the input field value to "Y":
'
function Password() {
var val = document.getElementById("IsFormSubmitted");
if(val.value == "N")
{
setTimeout(function () { $("#MyDiv").show(); }, 1500);
val.value = "Y";
}
};
Thank you for all the help and guidance :)