用findcontrol方法递归遍历你的页面中的所有控件 Public Function SearchCtl(ByVal ParentCtl As Control, ByVal SearchCtlID As String) As Control '根据Control ID查找某一实例Control的Controls集合及其子集合中的Control If ParentCtl Is Nothing Then Throw New NullReferenceException Else Try Dim Ctl As Control Dim ReturnCtl As Control For Each Ctl In ParentCtl.Controls If Not Ctl.ID Is Nothing Then If Ctl.ID.ToLower = SearchCtlID.Trim.ToLower Then ReturnCtl = Ctl Exit For Else ReturnCtl = SearchCtl(Ctl, SearchCtlID) If Not ReturnCtl Is Nothing Then Exit For End If End If Else ReturnCtl = SearchCtl(Ctl, SearchCtlID) If Not ReturnCtl Is Nothing Then Exit For End If End If Next Return ReturnCtl Catch ex As Exception Return Nothing End Try End If End Function 判断返回值,如果为空,说明没有,否则就有
Public Function SearchCtl(ByVal ParentCtl As Control, ByVal SearchCtlID As String) As Control
'根据Control ID查找某一实例Control的Controls集合及其子集合中的Control
If ParentCtl Is Nothing Then
Throw New NullReferenceException
Else
Try
Dim Ctl As Control
Dim ReturnCtl As Control
For Each Ctl In ParentCtl.Controls
If Not Ctl.ID Is Nothing Then
If Ctl.ID.ToLower = SearchCtlID.Trim.ToLower Then
ReturnCtl = Ctl
Exit For
Else
ReturnCtl = SearchCtl(Ctl, SearchCtlID)
If Not ReturnCtl Is Nothing Then
Exit For
End If
End If
Else
ReturnCtl = SearchCtl(Ctl, SearchCtlID)
If Not ReturnCtl Is Nothing Then
Exit For
End If
End If
Next
Return ReturnCtl
Catch ex As Exception
Return Nothing
End Try
End If
End Function
判断返回值,如果为空,说明没有,否则就有
如果能,就更好了。
.......
JavaScript区分大小写。
for(var t=0;t<m;t++)
{
if(window.document.Form1.elements[t].name.indexOf("aaa")!=-1)//找到
{
//do something
}
}