非常奇怪的问题(2005的新bug?)
红皮猴 2006-08-09 01:02:51 我的页面上有Photo1,Photo2,Photo3三个上传控件,当点Button后分别把传好的图片名称显示到3个label上,但是点击Button后3个label显示的内容是一样的,图片也只传上去1张。
反过来我在断点模式下按F11单步执行却所有的都正常(图片也3幅都传上去了,lable显示也正常)
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim P1, P2, P3 As String
Dim TP1, TP2, TP3 As String
TP1 = UPImage(Photo1)
TP2 = UPImage(Photo2)
TP3 = UPImage(Photo3)
If TP1 = "NO" Or TP2 = "NO" Or TP3 = "NO" Then
Exit Sub
Else
If TP1 <> "NULL" Then
P1 = TP1
End If
If TP2 <> "NULL" Then
P2 = TP2
End If
If TP3 <> "NULL" Then
P3 = TP3
End If
End If
label1.text=P1
label2.text=P2
label3.text=P3
End Sub
'上传图片
Function UPImage(ByVal FName As FileUpload) As String
Dim temp As String = "NO"
Dim PH As FileUpload
PH = FName
If Not String.IsNullOrEmpty(PH.PostedFile.FileName.Trim()) Then
If PH.PostedFile.ContentType.ToLower.StartsWith("image") Then
If PH.PostedFile.ContentLength / 1024 <= 1024 Then
Dim FileName, FileType As String
FileType = Path.GetExtension(PH.PostedFile.FileName).ToLower.ToString
FileName = DateTime.Now.ToString("yyyyMMddhhmmss") + FileType
PH.SaveAs(Server.MapPath("~/image/People/" + FileName))
temp = FileName
Return temp
Else
Response.Write(Base.Java_MessageBox("上传的文件不能大于1M!"))
Return temp
End If
Else
Response.Write(Base.Java_MessageBox("你上传的不是图片文件!"))
Return temp
End If
Else
temp = "NULL"
Return temp
End If
End Function