Check all - checkbox
-
Hi all I have a user privilages form, How can I make a checkbox that checks all the checkboxes in a form ? Thanks
Nour Abdel-Salam... A Trainer and a Web Developer in Jedda Int'l Computer Center(JICC)
There are several ways, client-side JavaScript to server-side events. Clarify your requirements and you may get a more precise answer.
only two letters away from being an asset
-
There are several ways, client-side JavaScript to server-side events. Clarify your requirements and you may get a more precise answer.
only two letters away from being an asset
-
Hi Mark I prefer to get the server side events if it possible.. Regards
Nour Abdel-Salam... A Trainer and a Web Developer in Jedda Int'l Computer Center(JICC)
Checkboxes has a CheckedChange event where you can verify if that checkbox is checked or not, and you check or uncheck the other checkboxes. You can use Ajax Update panel if you want to do this without refreshing your page :) Ex: protected void allTotals_CheckedChanged(object sender, EventArgs e) { if (allTotals.Checked) { customTotals1.Checked = false; customTotals2.Checked = false; customTotals3.Checked = false; customTotals4.Checked = false; .... } else { customTotals1.Checked = true; customTotals2.Checked = true; customTotals3.Checked = true; customTotals4.Checked = true; .... } }
-------------------------------- visit: http://pmartike.deviantart.com/
-
Checkboxes has a CheckedChange event where you can verify if that checkbox is checked or not, and you check or uncheck the other checkboxes. You can use Ajax Update panel if you want to do this without refreshing your page :) Ex: protected void allTotals_CheckedChanged(object sender, EventArgs e) { if (allTotals.Checked) { customTotals1.Checked = false; customTotals2.Checked = false; customTotals3.Checked = false; customTotals4.Checked = false; .... } else { customTotals1.Checked = true; customTotals2.Checked = true; customTotals3.Checked = true; customTotals4.Checked = true; .... } }
-------------------------------- visit: http://pmartike.deviantart.com/
More efficient code
protected void allTotals_CheckedChanged(object sender, EventArgs e) { customTotals1.Checked = allTotals.Checked; customTotals2.Checked = allTotals.Checked; customTotals3.Checked = allTotals.Checked; customTotals4.Checked = allTotals.Checked; }
Or even better yet, put the checkboxes in a containerprotected void allTotals_CheckedChanged(object sender, EventArgs e) { foreach(CheckBox c in Panel1.Controls) c.Checked = allTotals.Checked; }
only two letters away from being an asset
-
Checkboxes has a CheckedChange event where you can verify if that checkbox is checked or not, and you check or uncheck the other checkboxes. You can use Ajax Update panel if you want to do this without refreshing your page :) Ex: protected void allTotals_CheckedChanged(object sender, EventArgs e) { if (allTotals.Checked) { customTotals1.Checked = false; customTotals2.Checked = false; customTotals3.Checked = false; customTotals4.Checked = false; .... } else { customTotals1.Checked = true; customTotals2.Checked = true; customTotals3.Checked = true; customTotals4.Checked = true; .... } }
-------------------------------- visit: http://pmartike.deviantart.com/