Paul,
Is this a checkbox list or a single checkbox?
If it's a list then you have to specify which item in the list to check.
Another difficulty is the way .NET renders the list using columns. Here's a
script I wrote as part of a CheckBoxList Validator I created:
Dim StringBuilder As New Text.StringBuilder
StringBuilder.Append("<script language=""javascript"">" &
vbCrLf)
StringBuilder.Append("<!--" & vbCrLf)
StringBuilder.Append("function
checkboxlist_verification(clientID) {" & vbCrLf)
StringBuilder.Append("var val =
document.all[document.all[clientID].controltovalidate];" & vbCrLf)
StringBuilder.Append("var col = val.all;" & vbCrLf)
StringBuilder.Append("if (col != null ) {" & vbCrLf)
StringBuilder.Append("var checked = 0;" & vbCrLf)
StringBuilder.Append("var checkboxcount = 0;" & vbCrLf)
StringBuilder.Append("for (i = 0; i < col.length; i++ ) {" &
vbCrLf)
StringBuilder.Append("if (col.item(i).tagName == 'INPUT') {"
& vbCrLf)
StringBuilder.Append("checkboxcount += 1;" & vbCrLf)
StringBuilder.Append("if (col.item(i).checked ) {" & vbCrLf)
StringBuilder.Append("checked += 1;" & vbCrLf)
StringBuilder.Append("if (checked == " &
NumberOfCheckBoxesRequired & ") {" & vbCrLf)
StringBuilder.Append("return true;" & vbCrLf)
StringBuilder.Append("}" & vbCrLf)
StringBuilder.Append("}" & vbCrLf)
StringBuilder.Append("}" & vbCrLf)
StringBuilder.Append("}" & vbCrLf)
StringBuilder.Append("if (checked == checkboxcount) {" &
vbCrLf)
StringBuilder.Append("return true;" & vbCrLf)
StringBuilder.Append("};" & vbCrLf)
StringBuilder.Append("else {" & vbCrLf)
StringBuilder.Append("return false;" & vbCrLf)
StringBuilder.Append("}" & vbCrLf)
StringBuilder.Append("}" & vbCrLf)
StringBuilder.Append("}" & vbCrLf)
StringBuilder.Append("-->" & vbCrLf)
StringBuilder.Append("</script>" & vbCrLf)
ClientScriptManager.RegisterClientScriptBlock(Scri ptType,
"CheckBoxListVerification", StringBuilder.ToString())
The component I created lets you specify how many checkboxes in a
checkboxlist must be checked for the page to validate. If that's what you
happen to be attempting you may download the component which is free and
includes all source code from here:
http://www.aboutfortunate.com/defaul...tvalidatordemo
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"PJ6" <no****@nowhere.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
OnPreRender if I add this...
Me.Attributes.Add("onmousedown", "alert(this.checked)")
I get 'undefined', at least in IE. Everywhere I look "checked" is supposed
to be the property to retreive the value of a checkbox... obviously I've
missed something. Someone want to give me a clue?
Thanks,
Paul