Emerald Emerald - 1 year ago 82
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.


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
. 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 Source

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.