I wanted a RadNumericTextBox and a RadDateTimePicker to be loaded hidden, but later be made visible via javascript. Perhaps the most elegant solution is to use AJAX, but in my case I want the hide and unhide to always happen instantly, so javascript is the best choice. I found a work around for both, but it's ugly. Perhaps I overlooked something. Perhaps a future release can handle this issue better. Here's my solution.
Initialization
| Protected Overrides Sub CreateChildControls() |
| ... |
| RadDateTimePicker1.Style("display") = "none" |
| ... |
| RadNumericTextBox1.ClientEvents.OnLoad = "function(){$find(""" & RadNumericTextBox1.ClientID & """).set_visible(false);}" |
| ... |
| End Sub |
Javascript display function
| var display = function(control, visible) { |
| if (control.style) { //normal |
| control.style.display = visible ? "" : "none"; |
| } |
| else { |
| if (control._numberFormat) { //numeric |
| control.set_visible(visible); |
| } |
| else { //datetime |
| $get(control.get_id() + "_wrapper").style.display = visible ? "inline-block" : "none"; |
| } |
| } |
| } |
As odd as this approach is, it's the most straight forward one I could find. Any better suggestions?
