Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to check form after postback
    text
    copied!<p>Please cosider this scenario:</p> <p>I have a form with 3 drop down list.I place these controls in an <code>update panel</code>.when my users select an Item with value greater that 2 in first drop down list I disable second and third drop down list with jQuery. My problem is after any post back all drop down list are enable.I know this is normal but how I can check the form again and disable controls that should be disable?</p> <h2>thanks</h2> <p><strong>Edit 1)</strong></p> <p>this is my code:</p> <pre><code>&lt;asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"&gt; &lt;ContentTemplate&gt; &lt;table border="1" cellpadding="0" cellspacing="0"&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:DropDownList ID="DropDownList1" runat="server" Width="100px"&gt; &lt;asp:ListItem Value="1" Text="1" /&gt; &lt;asp:ListItem Value="2" Text="2" /&gt; &lt;asp:ListItem Value="3" Text="3" /&gt; &lt;/asp:DropDownList&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:DropDownList ID="DropDownList2" runat="server" Width="100px"&gt; &lt;asp:ListItem Value="1" Text="1" /&gt; &lt;asp:ListItem Value="2" Text="2" /&gt; &lt;asp:ListItem Value="3" Text="3" /&gt; &lt;/asp:DropDownList&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:DropDownList ID="DropDownList3" runat="server" Width="100px"&gt; &lt;asp:ListItem Value="1" Text="1" /&gt; &lt;asp:ListItem Value="2" Text="2" /&gt; &lt;asp:ListItem Value="3" Text="3" /&gt; &lt;/asp:DropDownList&gt; &lt;br /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;div&gt; &lt;asp:Button ID="Button1" runat="server" Text="Cause Post Back" Width="200px" onclick="Button1_Click"/&gt; &lt;/div&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; </code></pre> <p>and javascript:</p> <pre><code> $(document).ready(function () { function Disable(item) { item.attr('disabled', 'disabled'); } $('#DropDownList1').change(function () { if ($(this).val() &gt; 2) { Disable($('#DropDownList2')); Disable($('#DropDownList3')); } else { Enable($('#DropDownList2')); Enable($('#DropDownList3')); } }).change(); function Enable(item) { item.removeAttr('disabled'); } }); </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