Last post Sep 18, 2008 01:21 PM by zipswich
Sep 17, 2008 01:45 PM|zipswich|LINK
I have made a custom server control derived from BasCompareValidator. It uses method RegisterClientScriptBlock() to inject client script so users get feedback before sending the data. It has been working great until I put the control in a Panel that is
initially invisible. When the Panel is made visible after a button is clicked, an error message says Microsoft JScript runtime error:'ClinicalDateTimeValidatorIsValid' is undefined. ClinicalDateTimeValidatorIsValid is the method in the script. If the Panel
is made visible initially, everything works fine.
Could anyone provide some clue about how to get around this?
Sep 17, 2008 06:21 PM|jkirkerx|LINK
When a panel is made invisible via server side
.visible = False
The contents inside the panel are not rendered. So nothing exist
Sep 17, 2008 06:34 PM|zipswich|LINK
Thanks for your tip that I will try.
What is puzzling is that this problem happens only when the Panel is made
Visible. The script is needed only when the Panel is visible.
The alternating between visible and invisible works fine without that particular custom validator control. The form has other java scripts associated with almost every control. They have been working fine. However, this is the only piece of block script.
Sep 17, 2008 07:07 PM|jkirkerx|LINK
I thought it was the other way around. Don't try the suggustion.
Really need to look at the error code for better feedback or suggestions.
Got bowling tonight, back tomorrow.
Sep 18, 2008 10:35 AM|zipswich|LINK
I checked the source code from the browser (IE 6) as my first response to this problem, but could not find the script block meaning the script is not injected when the panel containing the control is made visible.
Though I still cannot figure out why the script is not injected, I took your tip and made it work by doing the following:
Sep 18, 2008 12:36 PM|jkirkerx|LINK
within the browser. So you won't be able to see changes in the browser source when they occur.
Sep 18, 2008 01:21 PM|zipswich|LINK
I forgot to mention that the Panel is an asp:Panel.
I already wrote quite some code working with the Panel, so I kept the panel to save me from modifying the code though I could remove the panel.
Initially I put style="visibility:
inside the panel treating it as a div. It does make the panel invisible, but the OnClientClick script (document.getElementById('pnlForm').style.visibility= "visible") did not work with the panel (I could be doing it not the right way) and this why I
put the panel inside to a div.