Mitchel Stuart Fountaine Mitchel Stuart Fountaine - 5 months ago 34
Ajax Question

Function not working after updatepanel triggered

I have this function on the same asp.net page that makes use of UpdatePanels

$(function() {
$("#listTimeInput").change(function() {
ToggleDropdown();
});
ToggleDropdown();
});

function ToggleDropdown() {
if ($("#listTimeInput").val() == "1") {
$("#dateBox").show();
} else {
$("#dateBox").hide();
}
};


This function works fine when the page is loaded, however after the UpdatePanel is triggered the function no longer works.

I am very new to JavaScript and am not sure if I need to wrap this code into the document.ready statement. I'm also not sure where that would go.

Any and all help would be appreciated.

Answer

use following approach..

function pageLoad(sender, args)
{
  $(document).ready(function(){   

   // put all your javascript functions here 

  });
} 

or referred to link

After postback my JavaScript function doesn't work in ASP.NET

Comments