All selection and reading selection in email processing with JavaScript

xiaoxiao2021-03-06  36

The following code implements the features we often encounter: When handling Email in the web page, there will be all selected or canceled Checkbox, and add the selected content to a TextBox.

There are two ways to implement: We assume that the mailing list is implemented with DataList, add CheckBox1 to the ItemTemplate to bind the library.

Using server control: Implemented in Checkbox's CheckedChanged event.

Private void CBSelectAll_Checkedchanged (Object Sender, System.Eventargs E)

{

IF (cbselectall.checked)

{

Checkbox CurrentCheckbox = new checkbox ();

Foreach (DatalistItem ItemChecked in Datalist1.Items)

{

CurrentCheckBox = (CHECKBOX) (ItemChecked.FindControl ("CheckBox1"));

CurrentCheckbox.checked = true;

}

}

Else

{

Checkbox CurrentCheckbox = new checkbox ();

Foreach (DatalistItem ItemChecked in Datalist1.Items)

{

CurrentCheckBox = (CHECKBOX) (ItemChecked.FindControl ("CheckBox1"));

CurrentCheckBox.checked = false;

}

}

}

This method is disadvantage that the reaction is too slow and does not adapt to customer needs.

Another way is to use JavaScript:

Add in HTML