Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The &lt;% %> works fine. One thing that I do is set a value in a hidden field on the page (then writing the necessary javascript to extract that value), this is nice because I can change that hidden field via javascript and when/if the page posts back I can get that new value from code behind as well.</p> <p>If you need to call the method on demand, you could do an jQuery AJAX call to a ASP.NET WebMethod to grab the data and re-populate the various options. You can find a good tutorial on how to do that here: <a href="http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/" rel="nofollow noreferrer">http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/</a></p> <p>Below is some sample code using the hidden field method (using the datepicker control, but you'll get the idea):</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._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;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:TextBox ID="txtCalendar" runat="server" /&gt; &lt;asp:HiddenField ID="hfTest" runat="server" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://ui.jquery.com/latest/ui/ui.datepicker.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var dateMinimum = new Date($("#&lt;%= hfTest.ClientID %&gt;").val()); $(function() { $("#&lt;%= txtCalendar.ClientID %&gt;") .datepicker({ minDate: dateMinimum }); }); &lt;/script&gt; &lt;/body&gt; </code></pre> <p></p> <p>And the code behind Page_Load method:</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { // Set Value of Hidden Field to the first day of the current month. this.hfTest.Value = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).ToString("MM/dd/yyyy"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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