Tuesday, May 26, 2009
TextBox enable Disable on checkChange
protected void rptrItem_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
CheckBox chk = (CheckBox)e.Item.FindControl("chkbxItem");
TextBox txt = (TextBox)e.Item.FindControl("txtQuantity");
txt.Attributes.Add("onkeypress", "return isNumberKey(event)");
txt.Attributes.Add("onpaste", "return false;");
chk.Attributes.Add("onclick", "if(this.checked) {document.getElementById('" + txt.ClientID + "').disabled = !this.checked;document.getElementById('" + txt.ClientID + "').style.backgroundColor ='white';document.getElementById('" + txt.ClientID + "').focus();}else{document.getElementById('" + txt.ClientID + "').style.backgroundColor ='CCCCCC';document.getElementById('" + txt.ClientID + "').disabled = true;}");
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment