Emerald Emerald - 1 month ago 13
ASP.NET (C#) Question

Datepicker is not working when adding runat="server"

I am referring to this site http://jqueryui.com/datepicker/ for datepicker and I am coding exactly like the source code given. Those coding is working fine.

But..

When I am adding runat="server" inside this piece of code

<input type="text" id="datepicker">
my calendar won't show up when clicking the
TextBox
. I need to put runat="server" so that I am able to use it at behind code.

Any suggestion from you guys would be much appreciated. Thank you.

Answer

I found a correct way to do it.

For ASP.Net design

<asp:TextBox runat="server" id="datepicker"></asp:TextBox>

On client server side

$(document).ready(function () { $("[id$=datepicker]").datepicker(); });

put $("[id$=datepicker]").datepicker(); instead of $('#<%= datepicker.ClientID %>').datepicker(); then calendar will be shown up and able to call the datepicker in code behind.

Comments