var s = checkbox.id.substr(0, checkbox.id.lastIndexOf("_") + 1) + "btnAgreeContinue"; ; >>>var button = document.getElementById(s); >>>button.disabled = !checkbox.checked;but there must be something a bit more elegant.....
>>mmButton thisButton = (mmButton)this.FindControlByName(this, "btnAgreeContinue"); >> >>StringBuilder sb = new StringBuilder(); >>sb.Append(@"<script language='javascript' type='text/javascript'>"); >>sb.Append(@"function SetAgreeAndContinue(checkbox) {"); >>sb.Append(@"var button = document.getElementById('" + thisButton.ID + "');"); >>sb.Append(@"button.disabled = !checkbox.checked;"); >>sb.Append(@"}"); >>sb.Append(@"</script>"); >> >>string myscript = sb.ToString(); >>Page.RegisterStartupScript("S", myscript); >>>
public Control FindControlByName<T>(T controlToSearch, string controlID) where T : System.Web.UI.Control { Control matchingControl = null; try { foreach (Control subControl in controlToSearch.Controls) { if (subControl.ID != null && subControl.ID.EndsWith(controlID)) { matchingControl = subControl; break; } else { if (matchingControl != null) // found it break; else if (subControl.HasControls()) { matchingControl = this.FindControlByName(subControl, controlID); } } } } catch (Exception e) { throw; } return matchingControl; }Tim