Reputation: 2143
I have a web page with a div:
<div runat="server" id="divNewCapture" style="padding-top: 30px; padding-bottom: 30px; padding-left: 20px">
...
</div>
Within this div I have an textbox that I use with a JQuery datepicker:
<input id="txtHtmlDateMarried" class="textEntry" style="width: 295px" />
$('#txtHtmlDateMarried').datepicker({
showOn: "button",
buttonImageOnly: true,
buttonImage: "Images/Calendar.png",
dateFormat: "yy/mm/dd",
});
Server-side on Page_Load I hide the div:
divNewCapture.Visible = false;
When I show this div again at a later stage, the datepicker for the textbox is lost. It shows initially if I don't hide the div. (I want to fix this without any server-side code)
Upvotes: 0
Views: 42
Reputation: 56688
Since divNewCapture
is a server-side control, setting its Visible
to false effectively removes the control from the page. I.e. when Visible
is false, control is not rendered. Therefore datepicker does not see it when you initialize it.
If you want to hide control but make sure it is still on the page and is available for javascript calls, then operate with style. To hide:
btnSaveLineItems.Style["display"] = "none";
to show:
btnSaveLineItems.Style.Remove("display");
//or
btnSaveLineItems.Style["display"] = "block";
However perhaps better style would be to manage control's visibility on the client side completely.
Upvotes: 1