Microsoft KB Archive/840545

= A frame in a frameset may become blank on an ASP page or in an ASP.NET application =

Article ID: 840545

Article Last Modified on 4/27/2004

-

APPLIES TO


 * Microsoft Internet Explorer (Programming) 6.0
 * Microsoft Internet Explorer (Programming) 6 (SP1)

-





SYMPTOMS
If you programmatically call the submit function in a form, and the form is on a page in a frameset, the response may not appear. Instead, the frame may become blank.

Typically, this problem occurs on an ASP page or in a Microsoft ASP.NET application that has the postback function enabled on a control that contains items that the user selects, such as ListBox control or a DropDownList control. This problem occurs when the user changes the selected item in the control.



CAUSE
This problem is a timing bug. This problem may occur if a call is made to the submit function from an onchange event handler at the same time that a response for a POST request is received.

In ASP.NET, this problem may occur if the user clicks a new item in the ListBox control or in the DropDownList control at the same time that the response for the previous postback request is received.



WORKAROUND
To work around this problem, use one of the following methods:
 * Workaround 1

Wait until the onchange event has completed and then call the submit function later by using a Timeout function.
 * Workaround 2

Prevent the user from performing another POST request by changing the HTML page in the onbeforeunload event.

For more information about how to use these workarounds, see the &quot;More information&quot; section.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section.



Steps to reproduce the problem in an ASP page
This example reproduces the problem and the workarounds in an ASP page.   Use the following sample code to create an HTML frameset page that is named Frameset.htm:      Use the following sample code to create an HTML frame page that is named Frame.asp: <% ' This delay is introduced to enable the user to generate another ' post at the same time that this response is received. dim y y = 0 for x = 1 to 100000 ' This setting can be modified to adjust the delay. y = y + x/10 next %>    <option value=&quot;Item1&quot;>Item1 <option value=&quot;Item2&quot;>Item2 <option value=&quot;Item3&quot;>Item3 <script language=&quot;javascript&quot;> function Workaround1 {   setTimeout(&quot;form1.submit&quot;, 1); } function Workaround2 {   document.body.innerHTML = &quot;Waiting for response.&quot;; } Note In this sample code, the onbeforeunload event handler is misspelled as &quot;onbeforeunloadx&quot; to disable the workaround for now. </li> Save the files that you created in steps 1 and 2 to a Web server.</li> In your Web browser, view the Frameset.htm file.</li> Click various items in the list box. Notice that every click triggers an onchange event, and every onchange event causes a POST request to be sent to the server again through the form1.submit function call.

If you click an item in the list box at the same time that a response is received, the frame becomes blank.</li> Implement one of the following workarounds at a time: <ul> Workaround 1

To implement the first workaround, modify the onchange event handler to call the Workaround1 function. This workaround creates a Timeout function. This Timeout function allows the submit call to be made after the onchange event has completed.</li> Workaround 2

To implement the second workaround, rename the &quot;onbeforeunloadx&quot; event handler as onbeforeunload. After you rename the onbeforeunload event handler, the event handler calls the Workaround2 function. The second workaround changes the contents of the page. This change prevents the user from clicking anything until the response has been received and has been rendered.</li></ul> </li></ol>

Steps to reproduce the behavior in ASP.NET
This example reproduces the problem in an ASP.NET application. <ol> Create an ASP.NET application. You can use either Visual Basic .NET or Visual C# .NET. However, these steps use Visual C# .NET.

By default, a file that is named WebForm1.aspx is created.</li>  Modify the HTML in the WebForm1.aspx file so that it contains a frameset. In this frameset, one frame points to the about:blank page, and the other frame points to a new form that you will create in step 3. To do this, add the following code to the WebForm1.aspx file: <frameset cols=&quot;110,*&quot;> <frame src=&quot;about:blank&quot; scrolling=&quot;no&quot; frameborder=&quot;yes&quot;> <frame src=&quot;WebForm2.aspx&quot; scrolling=&quot;no&quot; frameborder=&quot;yes&quot;> </li> Create a new ASP.NET form that is named WebForm2.aspx.</li> Add a Web Form ListBox control. Enable the AutoPostBack property of the ListBox control.</li> Add three list items to the ListBox control. To do this, edit the Items property of the ListBox control.</li>  To simulate the delay, add code in the Page_Load event handler of the WebForm2.aspx file to delay the response for 500 milliseconds (msec). using System.Threading; ...   public class WebForm2 : System.Web.UI.Page {       protected System.Web.UI.WebControls.ListBox ListBox1; private void Page_Load(object sender, System.EventArgs e)       { Thread.Sleep(500); } ... </li> Build the project, and then open the WebForm1.aspx file in your Web browser.</li></ol>

If you click various list box items at exactly the correct time, the frame becomes blank. The timing of this click is approximately 500 msec after the last click, plus any network delays.

Keywords: kbpending kbbug KB840545

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.