Ciao a tutti.

Ho uno stranissimo problema quando utilizzo il Response Write nell'evento Page Load di un code behind di una pagina C#.

L'utilizzo del Response Write stravolge e cambia il layout css della pagina aspx dove è pubblicata la GridView, saltano i caratteri, i colori, etc.

Da cosa può dipendere?
Grazie

Articolo di riferimento: http://support.microsoft.com/kb/837375

codice:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;

public partial class WebForm1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Response.Write("<div id='mydiv' class=loading>");
        this.Response.Write("_");
        this.Response.Write("</div>");
        this.Response.Write("<script>mydiv.innerText = '';</script>");

        this.Response.Write("<script language=javascript>;");
        this.Response.Write("var dots = 0;var dotmax = 10;function ShowWait()");
        this.Response.Write("{var output; output = 'Loading';dots++;if(dots>=dotmax)dots=1;");
        this.Response.Write("for(var x = 0;x < dots;x++){output += '.';}mydiv.innerText =  output;}");
        this.Response.Write("function StartShowWait(){mydiv.style.visibility = 'visible'; window.setInterval('ShowWait()',1000);}");
        this.Response.Write("function HideWait(){mydiv.style.visibility = 'hidden';window.clearInterval();}");
        this.Response.Write("StartShowWait();</script>");

        this.Response.Flush();
        Thread.Sleep(10000);

        GridView1Source();
    }
}






<%@ Page Language="C#" AutoEventWireup="true" CodeFile="WebForm1.aspx.cs" Inherits="WebForm1" %>

<!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>
    <script type="text/javascript" language="javascript">
        HideWait();
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
       >>> gridView, etc <<<
    </div>
    </form>
</body>
</html>