Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Utilizzo Response Write cambia layout pagina

    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>

  2. #2
    Utente di HTML.it L'avatar di rsdpzed
    Registrato dal
    Aug 2001
    Messaggi
    764
    metti un controllo LITERAL nel punto in cui vuoi scrivere quella roba e scrivi nell'innerhtml del literal invece che nel Response

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.