locked
If file is attached to the Response why it cannot be saved when webpage is in frameset? RRS feed

  • Question

  • User-1252119795 posted

    I have written a code to export dataset to tab delimited text file which works fine if only page is in browser (IE).

    But my application has a frameset page where I need to use this (export) page in one of the frame and there I cannot save or open the exported file.

    It shows Open | Save | Cancel dialog but when clicked on Open or Save another dialog appears -

    "Getting File Information: 

     frmExport.aspx from <webserver name>" and nothing till I close the dialog.

    My code is:

    -----------------------------------------------------------------------------

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim dsExport As DataSet, objEmp As New clsExport
    dsExport = objEmp.GetECTranslation(3)
    Dim attachment As String = "attachment; filename=EvaluationAreaTranslation.txt"
    Response.ClearContent()
    Response.AddHeader("content-disposition", attachment)
    Response.ContentType = "text/txt"
    Dim iRowCnt As Int32 = 0, iColCnt As Int32 = 0
    Dim tab As String = ""
    Dim dc As DataColumn
    For Each dc In dsExport.Tables(0).Columns
    If dc.ColumnName <> "ECID" And dc.ColumnName <> "MODELID" And dc.ColumnName <> "TYPE" Then
    Response.Write(tab & dc.ColumnName.ToUpper)
    tab = vbTab
    If iColCnt = 2 Then Response.Write(tab & "EVALUATION AREA")
    End If
    iColCnt += 1
    Next
    Response.Write(vbCrLf)
    Dim dr As DataRow
    For Each dr In dsExport.Tables(0).Rows
    tab = ""
    For iColCnt = 0 To dsExport.Tables(0).Columns.Count - 1
    If iColCnt <> 0 And iColCnt <> 1 And iColCnt <> 3 Then
    If iColCnt = 2 Then
    If iRowCnt > 0 Then
    Response.Write(tab & "")
    Else
    Response.Write(tab & dr(iColCnt).ToString)
    End If
    tab = vbTab
    If dr(3) = 1 Then
    Response.Write(tab & dr(5).ToString)
    Else
    Response.Write(tab & "")
    End If
    Else
    Response.Write(tab & dr(iColCnt).ToString)
    End If
    End If
    Next
    Response.Write(vbCrLf)
    iRowCnt += 1
    Next
    Response.End()
    End

      Dim dsExport As DataSet, objEmp As New clsExport

      dsExport = objEmp.GetData()

      Dim attachment As String = "attachment; filename=Data.txt"

      Response.ClearContent()

      Response.AddHeader("content-disposition", attachment)

      Response.ContentType = "text/txt"

      Dim tab As String = ""

      Dim dc As DataColumn

      For Each dc In dsExport.Tables(0).Columns

        Response.Write(tab & dc.ColumnName.ToUpper)

        tab = vbTab

      Next

      Response.Write(vbCrLf)

      Dim dr As DataRow

      For Each dr In dsExport.Tables(0).Rows

        tab = ""

        For iColCnt = 0 To dsExport.Tables(0).Columns.Count - 1

          Response.Write(tab & dr(iColCnt).ToString)

          tab = vbTab

        Next

        Response.Write(vbCrLf)

      Next

      Response.End()

    End Sub

    -----------------------------------------------------------------------------

    If anybody has a solution pls help me out. Thanks.

    Thursday, November 12, 2009 12:18 AM

Answers

  • User371668647 posted

    I would guess that it's trying to re-request the page from the frame to do the Open/Save process from the frame and the button click handler is unable to fire in that context.

    Try making your export a standalone page (no click required) and see if that gets the desired behavior.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 13, 2009 2:05 PM

All replies

  • User371668647 posted

    I would guess that it's trying to re-request the page from the frame to do the Open/Save process from the frame and the button click handler is unable to fire in that context.

    Try making your export a standalone page (no click required) and see if that gets the desired behavior.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 13, 2009 2:05 PM
  • User-1252119795 posted

    thanks stiletto, I will try your suggestion but when I have tested the code on other machines it works just fine (with frames), so I think I should check for updates of my OS (Win-XP) or updates/settings of browser (IE 7), if any, or access rights to the machine or something like this. I am working on it.

    Monday, November 16, 2009 2:25 AM
  • User371668647 posted

    Just remember that in web apps we can only make recommendations about how to behave to the browser and every browser can do its own thing with the recommendations that we have made...

    Monday, November 16, 2009 9:57 AM