How to find a checkbox in repeater and implement a Select all delete

Source: Internet
Author: User

The checkbox uses the client control and adds the Ruanat=server property to the checkbox inside the Repeater
The properties of the Chktotal in the header must not be added to this property ....
Then select all of the JavaScript code
function Checkall ()
{
var e=document.aspnetform.elements;
var o;
for (Var i=0;i<e.length;i++)
{
o = e;
if (o.type== "checkbox" &o.id!= "Chktotal")
{
o.checked = document.getElementById ("Chktotal"). Checked;
}  }  }
Then decide if there is a selection, if there is no prompt!
function SelectOne ()
{
var e=document.aspnetform.elements;
var o;
var anyonechecked = false;
for (Var i=0;i<e.length;i++)
{
o = e;
if (o.type== "checkbox" & O.checked==true &o.id!= "Chktotal")
{
Anyonechecked = true;
Break
}
}
if (!anyonechecked)
{
Alert ("A project must be selected! ");
} }
Add a client control event to the deleted button
Delete event in background ... Note When binding the data, place the primary key (the unique index to be deleted as a hidden item in Reperter)
protected void Btndelete_click (object sender, EventArgs e)
{
for (int i = 0; i < RptMessList.Items.Count; i++)
{
if ((HtmlInputCheckBox) This.rptMessList.Items.FindControl ("Chkone"). Checked = = True)
{
int k = Ucar.Common.ConvertHelper.GetInteger ((RptMessList.Items.FindControl ("Hfid") as HiddenField). Value);
Bomessageds Bomessmodel = Bomessage.getmodel (k);
if (Bomessmodel! = null)
{
bomessmodel.ispublisheractive = 0;
Bomessage.update (Bomessmodel);
Ucar.Common.ScriptHelper.ShowAlertScript (this. Page, "Delete succeeded!" ");
}
}
}
The deletion behind me is the tombstone, the replacement state, we can directly delete can thank you to appreciate!
DataBind ();
}

<script language= "JavaScript">
<!--

function CA (frm)
{
var trk=0;
for (Var i=0;i<frm.elements.length;i++)
{
var e=frm.elements;
if (e.name! = ' Allbox ') && (e.type== 'checkbox') && (e.name! = ' do not want to be selectedcheckbox's name '))
{
trk++;
e.checked=frm.allbox.checked;
frm.del.disabled = frm.allbox.checked?false:true;//Select AllEffects on the disabled property of the Delete button
}
}
}

function CCA (FRM,CB)
{
var tb=to=0;
for (Var i=0;i<frm.elements.length;i++)
{
var e=frm.elements;
if (e.name! = ' Allbox ') && (e.type== 'checkbox') && (e.name! = ' do not want to be selectedcheckbox's name '))
{
tb++;
if (e.checked)
to++;
}
}
Frm.allbox.checked= (TO==TB) True:false;

if (0==to)//all unchecked and selected some effects on the disabled property of the Delete button
{
Frm.del.disabled = true;
}
Else
{
frm.del.disabled = false;
}
}

-
</script>


Call Method:
Select AllThe name is set to Allbox,onclick
Event execution CA (this.form);
Select the Checbox of the itemonclickEvent implementation CCA (This.form,this);

How to find a checkbox in repeater and implement a Select all delete

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.