按钮提交后,保存数据,页面变成黑色,中间屏幕显示小正方形图像

时间:2019-06-26 09:35:39

标签: asp.net vb.net

提交按钮后,单击更新命令正在执行,并更新具有转换后的字节值的表,并且页面变为黑色,页面中心带有白色小边框。

我已经在3到4台单独的计算机上进行了测试,但是得到了相同的结果。也使用断点检查。在Google上搜索,但未找到任何相关解决方案。

Protected Sub btnFileupload_Click(sender As Object, e As EventArgs) Handles btnFileupload.Click

        Dim filename As String = ""
        Dim filePath As String = ""
        'Dim fs As FileStream = New FileStream()
        Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("dsejConnectionString").ConnectionString)
        Dim cmdInsert As New SqlCommand()
        Dim query As String = "update management_approvaltbl set "

        If Not fileExtension Is Nothing Then
            If fileExtension.HasFile Then
                query += "prev_recognition_ext_affli_order_copy=@prev_recognition_ext_affli_order_copy,"
            End If
        ElseIf Not Session("fileExtension") Is Nothing Then
            query += "prev_recognition_ext_affli_order_copy=@prev_recognition_ext_affli_order_copy,"
        End If

        query = query.Substring(0, (query.Length() - 1))
        query = query & " where mgmtapprid=@mgmtapprid"

        cmdInsert = New SqlCommand(query, con)
        '1
        If Not fileExtension Is Nothing Then
            If fileExtension.HasFile Then
                Dim sizeca = fileExtension.PostedFile.ContentLength
                If checkPhoto(fileExtension.PostedFile.FileName) = False Then
                    lblmsg.Text = "Previous Recognition/Extension/Affiliation order copy " & txt
                    Exit Sub
                End If
                If sizeca > 1000000 Then
                    fileExtension = Nothing
                    lfileExtension.CssClass = "err"
                    lfileExtension.Text = "File size exceeded"
                    Exit Sub
                Else
                    lfileExtension.CssClass = "success"
                    'fileExtension = DirectCast(Session("fileExtension"), FileUpload)
                    filename = Now.Hour & Now.Minute & Now.Second & Now.Millisecond & "_" & fileExtension.PostedFile.FileName.ToString()
                    fileExtension.PostedFile.SaveAs(Server.MapPath("Photo/" & filename))
                    If CheckImage(filename) <> True Then
                        lblmsg.Text = "Kindly Upload Proper File"
                        lfileExtension.Text = "Not a valid .jpg file"
                        Exit Sub
                    End If
                    lfileExtension.Text = filename
                    Dim b1 As Byte() = toBinary(filename)
                    cmdInsert.Parameters.AddWithValue("@prev_recognition_ext_affli_order_copy", Data.SqlDbType.Image).Value = b1
                End If
            ElseIf Not Session("fileExtension") Is Nothing Then
                fileExtension = DirectCast(Session("fileExtension"), FileUpload)
                filename = Now.Hour & Now.Minute & Now.Second & Now.Millisecond & "_" & fileExtension.PostedFile.FileName.ToString()
                fileExtension.PostedFile.SaveAs(Server.MapPath("Photo/" & filename))
                If CheckImage(filename) <> True Then
                    lblmsg.Text = "Kindly Upload Proper File"
                    lfileExtension.Text = "Not a valid .jpg file"
                    Exit Sub
                End If
                lfileExtension.Text = filename
                Dim b11 As Byte() = toBinary(filename)
                cmdInsert.Parameters.AddWithValue("@prev_recognition_ext_affli_order_copy", b11)
            End If
        ElseIf Not Session("fileExtension") Is Nothing Then
            fileExtension = DirectCast(Session("fileExtension"), FileUpload)
            filename = Now.Hour & Now.Minute & Now.Second & Now.Millisecond & "_" & fileExtension.PostedFile.FileName.ToString()
            fileExtension.PostedFile.SaveAs(Server.MapPath("Photo/" & filename))
            If CheckImage(filename) <> True Then
                lblmsg.Text = "Kindly Upload Proper File"
                lfileExtension.Text = "Not a valid .jpg file"
                Exit Sub
            End If
            lfileExtension.Text = filename
            Dim b1_ As Byte() = toBinary(filename)
            cmdInsert.Parameters.AddWithValue("@prev_recognition_ext_affli_order_copy", b1_)
        End If

        If query <> "update management_approvaltbl set where mgmtapprid=@mgmtapprid" Then
            cmdInsert.Parameters.AddWithValue("@mgmtapprid", 1)
            con.Open()
            Dim i As Integer = cmdInsert.ExecuteNonQuery()
            con.Close()
            If i > 0 Then
                'ScriptManager.RegisterStartupScript(Me, Me.GetType, "Script", "displayMessage('Record saved successfully');", True)
                'ScriptManager.RegisterStartupScript(Me, Me.GetType(), "Script", "displayMessage('Record saved successfully');", True)
                lblmsg.Text = "Record saved successfully."
                Exit Sub
            Else
                lblmsg.Text = "Some error occured while saving the data."
            End If
        Else
            'Response.Redirect("SimplaPage.aspx", True)
            ScriptManager.RegisterStartupScript(Me, Me.GetType(), "Script", "displayMessage('Must Upload Atleast One File');", True)
            Exit Sub
        End If

    End Sub

命令执行后,我在标签上显示了一条确认消息。那应该是可见的。

0 个答案:

没有答案