Wednesday, March 28, 2012

UpdatePanel - Javascript to create control wont fire

I've got an update panel that functions like tabs, hiding/showing certain controls. One of the controls is rendered via javascript:

<script type="text/javascript" language="JavaScript">
showCategoryBox("Databases", "All Resources");
</script>

This creates a dropdown list to choose from. It works fine when the page loads, but going to other tabs, then coming back to this one causes it to disappear. All of the standard html controls show up fine, but it won't execute this script to create the dropdown.

Any Ideas? Thanks

Coop

Try something like this. The pageLoaded event of the PageRequestManager is raised after every postback, synchronous or asynchronous.

<script type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_pageLoaded(onPageLoaded);

function onPageLoaded(sender, args) {
showCategoryBox("Databases", "All Resources");
}
</script>


Thanks. I tried this (and something very similar by using ScriptManager in the cs file) and it just basically only shows this drop down, nothing else on the page shows up. The page starts to render, then everything goes blank and only this shows up at the top.

No comments:

Post a Comment