Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to enable a button when all the fields of form get field?
    primarykey
    data
    text
    <p>In my form there almost 30-35 controls, some are enabled and some are disabled like spouse name is disabled if the the person is unmarried and if the user selects that they are married the control get enabled.</p> <p>Initially the submit button is disabled but as soon as all enabled fields are filled I want the submit button to automatically enable itself.</p> <p>I have done this code for this purpose.</p> <pre><code>if ((nametxt.Text != null) &amp;&amp; (f_nametxt.Text != null) &amp;&amp; (m_nametxt.Text != null) &amp;&amp; (gotra_txt.Text != null) &amp;&amp; (panthcb.Text != null) &amp;&amp; (fhntext.Text != null) &amp;&amp; (edulvlcb.Text != null) &amp;&amp; (bloodcb.Text != null) &amp;&amp; (MarritalStatus != null) &amp;&amp; (s_nametxt.Text != null) &amp;&amp; (s_edulvlcb.Text != null) &amp;&amp; (s_bgcb.Text != null) &amp;&amp; (ressi_addresstxt.Text != null) &amp;&amp; (ressi_phnotxt.Text != null) &amp;&amp; (mobi_notxt.Text != null) &amp;&amp; (office_addresstxt.Text != null) &amp;&amp; (occup_typetxt.Text != null) &amp;&amp; (occup_naturecb.Text != null) &amp;&amp; (office_phno1txt.Text != null) &amp;&amp; (office_mobnotxt.Text != null)) { submit_addbtn.Enabled = true; } </code></pre> <p>I don't whether this is correct or not and where (at which event of form) I should do this.</p> <p>Please tell me and help me.</p> <p>Here is the code done keydown event of text boxes and this event is not triggering </p> <pre><code> private void mobi_notxt_KeyDown(object sender, KeyEventArgs e) { foreach (Control c in this.Controls) { TextBox txt = c as TextBox; if (txt != null) { if (!(txt.Enabled &amp;&amp; txt.Text != "")) { allFilled = false; break; } } } if (allFilled) { submit_addbtn.Enabled = true; } else { submit_addbtn.Enabled = false; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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