下面是一個類中的事件。 
Public Sub Insert(ByVal strSql As String)
        Try
            Comm.CommandText = strSql
            Comm.ExecuteNonQuery()
'----------------------------------下句有問題
            Response.Write("<script>alert('成功');<script>")
         Catch ex As Exception
         
            Response.Write("<script>alert('失敗');<script>")
        End Try    End Sub

解决方案 »

  1.   

    出現這樣的錯誤
    -----------------------
    Response is not available in this context. 
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
      

  2.   

    Public Sub Insert(ByVal strSql As String,System.Web.UI.Page page)
            Try
                Comm.CommandText = strSql
                Comm.ExecuteNonQuery()
    '----------------------------------下句有問題
                page.Response.Write("<script>alert('成功');<script>")
             Catch ex As Exception
             
                page.Response.Write("<script>alert('失敗');<script>")
            End Try    End Sub调用的时候Insert(sql,this.page)
      

  3.   

    System.Web.HttpContext.Current.Response.Write("<script>alert('失敗');<script>")