Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
(ASP.NET VB)从变量引用控件_Asp.net_Vb.net_Variables_Controls - Fatal编程技术网

(ASP.NET VB)从变量引用控件

(ASP.NET VB)从变量引用控件,asp.net,vb.net,variables,controls,Asp.net,Vb.net,Variables,Controls,我试图创建一个循环进程,隐藏包含任何没有有效图像URL的图像控件的分隔符,但出现了一个错误:从字符串img1work1到类型“Integer”的转换无效。 代码如下: Dim i As Integer Dim imgWork1 As Image For i = 1 To 6 imgWork1 = Me.Controls("img" & i & "work1") Dim imageExi

我试图创建一个循环进程,隐藏包含任何没有有效图像URL的图像控件的分隔符,但出现了一个错误:从字符串img1work1到类型“Integer”的转换无效。 代码如下:

        Dim i As Integer
        Dim imgWork1 As Image
        For i = 1 To 6
            imgWork1 = Me.Controls("img" & i & "work1")
            Dim imageExists As String = Server.MapPath(imgWork1.ImageUrl)
            If Not (File.Exists(imageExists)) Then
                div1Work1.Visible = False
            End If
        Next
控件是ControlCollection,需要一个整数作为索引器。如果要按id获取控件,则必须使用FindControl


参考资料:

谢谢,我用me.findcontrol替换me.controls解决了这个问题