在IE9中可见非常短的iframe然后消失

时间:2013-05-17 10:24:55

标签: asp.net

我有一个位于网页上的usercontrol,该网页显示在iFrame中。

表格来源:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="FileUploadForm.aspx.vb"
Inherits="IST.FileUploadForm" %>

<%@ Register Src="myFileUpload.ascx" TagName="myFileUpload" TagPrefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head runat="server">
    <title></title>
  </head>
  <body>
    <form id="form1" runat="server">
      <div>
        <asp:PlaceHolder ID="ph1" runat="server"></asp:PlaceHolder>
      </div>
    </form>
  </body>
</html>

代码背后:

Imports System.IO

Public Class FileUploadForm
  Inherits System.Web.UI.Page

  Private WithEvents myFileUpload1 As myFileUpload

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim myUploadLocation As String

    myUploadLocation = Request.QueryString("loc")
    If myUploadLocation = Nothing Then
      myUploadLocation = Server.MapPath("~\temp")
    End If

    Dim allowed As String

    allowed = Request.QueryString("accepts")
    If allowed = Nothing Then
      allowed = ""
    End If

    myFileUpload1 = CType(Me.LoadControl("myFileUpload.ascx"), myFileUpload)
    myFileUpload1.ID = "fuOfferte"
    myFileUpload1.AllowedFiles = allowed
    myFileUpload1.FileLabelText = "File"
    myFileUpload1.NotAllowedText = "This file extention is not allowed."
    myFileUpload1.UploadButtonText = "Upload file"
    myFileUpload1.UploadLocation = myUploadLocation

    ph1.Controls.Add(myFileUpload1)

  End Sub

  Private Sub myFileUpload1_FileUploaded(file As String) Handles myFileUpload1.FileUploaded
    Session("UploadedFileName") = file
  End Sub
End Class

主页中的代码背后:

pnMNCfile = New Panel
pnMNCfile.ID = "pnMNCfile"
pnMNCfile.Style("position") = "absolute"
pnMNCfile.Style("left") = "45px"
pnMNCfile.Style("top") = "30px"
pnMNCfile.Style("width") = "540px"
If Request.Browser.Browser.ToLower = "ie" = False Or (Request.Browser.Browser.ToLower = "ie" = True And CInt(Request.Browser.Version.Substring(0, 1)) > 8) Then
  pnMNCfile.Style("height") = "80px"
Else
  pnMNCfile.Style("height") = "87px"
End If
pnMNCfile.Style("z-index") = "999"
pnMNCfile.BorderStyle = BorderStyle.None
pnMNCfile.BackColor = Drawing.Color.LightGray
pnMNCfile.BorderWidth = 1
pnMNCfile.Attributes.Add("OnMouseOut", "BalloonPopupControlBehavior.hidePopup();")
pnMNC3.Controls.Add(pnMNCfile)

Dim lit As New Literal
lit.Text = "<IFRAME id=""frMNCfileUpload"" frameborder=""0"" scrolling=""auto"" allowtransparency=""true"" runat=""server"" width=""100%"" height=""100%"" src=""FileUploadForm.aspx?loc=" + CStr(Session("userfolder")) + "&accepts=xls_xlsx_doc_docx""></IFRAME>"
pnMNCfile.Controls.Clear()
pnMNCfile.Controls.Add(lit)

问题是当在IE9中加载页面时,您很快就会看到iframe(小于0.5秒)。在Chrome中,它没有任何问题。 当我在iframe区域中右键单击并刷新时,内容可见。

我也试过围绕iframe的边框。当它不可见时,边框也不可见。在chrome中,您也可以看到边框。

这里发生了什么? 这是IE中的错误还是(更有可能)我做错了什么? 糟糕的修复方法是使用usercontrol为网页添加自动刷新。

有什么想法吗?

RG, 埃里克

1 个答案:

答案 0 :(得分:1)

I had the same issue with IE9 for various reasons and works with Chrome.

1. Configure Asp.net to use a cookieless session state. This might help...

    <sessionState cookieless="true" mode="InProc"></sessionState>
  </system.web>

</configuration>

or

2.

or try this too:

Response.Cache.SetCacheability(HttpCacheability.NoCache);

example:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GeneralLedgerCodeListingCustomForm.aspx.cs" Inherits="xyz.GeneralLedgerCodeListingCustomForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
%>