Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well if your using the jquery U.I datepicker why not use the built in disable command? So on post back you just disable it.</p> <p>Of course the textbox will be disabled as well but I am assuming that's what you want too.</p> <p>// jquery ui has a built in icon that shows up automatically <a href="http://jqueryui.com/demos/datepicker/#icon-trigger" rel="noreferrer">http://jqueryui.com/demos/datepicker/#icon-trigger</a></p> <p>// how to disable jquery ui. <a href="http://jqueryui.com/demos/datepicker/#method-disable" rel="noreferrer">http://jqueryui.com/demos/datepicker/#method-disable</a></p> <p>Here is how to disable the box once a post back happens. I am not clear if you want this to happen right after they enter something in the textbox or not though.</p> <p>Default.aspx</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;link href="ui.all.css" rel="stylesheet" type="text/css" /&gt; &lt;link href="ui.core.css" rel="stylesheet" type="text/css" /&gt; &lt;link href="ui.datepicker.css" rel="stylesheet" type="text/css" /&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(function() { $("#txtMyTextBox").datepicker({ showOn: 'button', buttonImage: 'images/calendar.gif', buttonImageOnly: true }); var disabled = $('#txtMyTextBox').attr('disabled'); if (disabled == true) { $("#txtMyTextBox").datepicker('disable'); } else { $("#txtMyTextBox").datepicker('enable'); } }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:TextBox ID="txtMyTextBox" runat="server" Enabled="false"&gt;&lt;/asp:TextBox&gt; &lt;asp:Button ID="enable" runat="server" Text="enable" onclick="enable_Click" style="width: 56px" /&gt; &lt;asp:Button ID="disable" runat="server" Text="disable" onclick="disable_Click" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>code behind</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void enable_Click(object sender, EventArgs e) { txtMyTextBox.Enabled = true; } protected void disable_Click(object sender, EventArgs e) { txtMyTextBox.Enabled = false; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload