0

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.

Satpal
  • 132,252
  • 13
  • 159
  • 168

2 Answers2

1

Try calling it in the ajax pageLoad method.

e.g.

function pageLoad(sender, args) {
   your code
}

btw it's Javascript not Java :)

H77
  • 5,859
  • 2
  • 26
  • 39
0

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

Community
  • 1
  • 1
Waqas
  • 847
  • 4
  • 14
  • 36