Hi,
I am having major issues using UpdatePanels on a website. The problem is that when i use a ScriptManager, all client side JavaScript that was active when the page was originally loaded is lost once an update panel posts back.
Here's what i'm trying to do...
I have a number of .net calender controls on the same page each within its own update panel. The calendars are initially hidden, until you click within an associated text box (also within the update panel), at that point the calender pops up so you can select a date. They calendars work great untill you actually change the date (post back), after which the calenders no longer pop up when you click within the text boxes, the "onfocus" JavaScript is lost.
After looking on google for what seems like hours, I can get things semi-working by dynamically adding an "onfocus" attribute to the TextBox and registering start up script with the ScriptManager when the calendar posts back.
Example:
TextBox1.Attributes.Add("onfocus", "document.getElementById('searchArrivalDateCalendarDiv').style.display = 'block';")
ScriptManager.RegisterStartupScript(Page, GetType(Page), "StopTxtClick", "$(document).ready(function(){$('.txtArrivalDate').click(function(event){event.stopPropagation(); $('div.searchArrivalDateCalendarDiv').show(); });});", True)
This seems really impractical, especially when I introduce a master page. I'm going to end up having to re-register a hell of a lot of start up script.
There must be an easier way?