Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1555 connectés 

  FORUM HardWare.fr
  Programmation
  C#/.NET managed

  ASP.NET SaveAs

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

ASP.NET SaveAs

n°1331577
the big be​n
Posté le 24-03-2006 à 11:37:24  profilanswer
 

Bonjour,
 
Voici mon problème: sur click d'un boutton d'une page web, je doit créer un fichier excel puis faire apparaitre une boite de dialogue "SaveAs" permettant à l'utilisateur de choisir la destination et le nom du fichier.
 
Donc pour l'instant, je créer le ficheir, je l'enregistre dans un répertire temporaire sur le serveur puis j'execute le code suivant:

Code :
  1. PhysicalPath := string(session['PhysicalPath']);
  2.     try
  3.       //exit if file does not exist
  4.       If (Not System.IO.File.Exists(PhysicalPath)) then
  5.            exit;
  6.       objFileInfo := System.IO.FileInfo.Create(PhysicalPath);
  7.       Response.Clear();
  8.       //Add Headers to enable dialog display
  9.       Response.AddHeader('Content-Disposition', 'attachment; filename=' + objFileInfo.Name);
  10.       Response.AddHeader('Content-Length', objFileInfo.Length.ToString());
  11.       Response.ContentType := 'application/octet-stream';
  12.       Response.WriteFile(objFileInfo.FullName);
  13.     except on e : Exception do
  14.       Response.&End;
  15.     end;


 
Il m'enregiste alors le fichier mais pas que le ficheir xls il fait un fichier xml avec le reste du code HTML de ma page...  
 
Donc 2ème solution déja moins belle, j'ouvre une page SaveAs dans une nouvelle fenetre (via javascript) et je sauve ca fonctionne mais alors j'aimerais fermer la page dès que mon code est exécuter. J'ai essayé :

Code :
  1. Response.Write('<body><script>window.Close; </script></body>');


mais ca ne fait rien!!!!
 
D'avance merci
 
Ben

mood
Publicité
Posté le 24-03-2006 à 11:37:24  profilanswer
 

n°1331654
moi23372
Posté le 24-03-2006 à 12:58:21  profilanswer
 

the big ben a écrit :

Bonjour,
 
Voici mon problème: sur click d'un boutton d'une page web, je doit créer un fichier excel puis faire apparaitre une boite de dialogue "SaveAs" permettant à l'utilisateur de choisir la destination et le nom du fichier.
 
Donc pour l'instant, je créer le ficheir, je l'enregistre dans un répertire temporaire sur le serveur puis j'execute le code suivant:

Code :
  1. PhysicalPath := string(session['PhysicalPath']);
  2.     try
  3.       //exit if file does not exist
  4.       If (Not System.IO.File.Exists(PhysicalPath)) then
  5.            exit;
  6.       objFileInfo := System.IO.FileInfo.Create(PhysicalPath);
  7.       Response.Clear();
  8.       //Add Headers to enable dialog display
  9.       Response.AddHeader('Content-Disposition', 'attachment; filename=' + objFileInfo.Name);
  10.       Response.AddHeader('Content-Length', objFileInfo.Length.ToString());
  11.       Response.ContentType := 'application/octet-stream';
  12.       Response.WriteFile(objFileInfo.FullName);
  13.     except on e : Exception do
  14.       Response.&End;
  15.     end;


 
Il m'enregiste alors le fichier mais pas que le ficheir xls il fait un fichier xml avec le reste du code HTML de ma page...  
 
Donc 2ème solution déja moins belle, j'ouvre une page SaveAs dans une nouvelle fenetre (via javascript) et je sauve ca fonctionne mais alors j'aimerais fermer la page dès que mon code est exécuter. J'ai essayé :

Code :
  1. Response.Write('<body><script>window.Close; </script></body>');


mais ca ne fait rien!!!!
 
D'avance merci
 
Ben


 
J'ai fais plus ou moins pareil avec un fichier xml dernièrement.
 

Code :
  1. /*Création du fichier xml de la tournée*/
  2. System.Xml.XmlTextWriter myXmlWriter = new System.Xml.XmlTextWriter(new System.IO.FileStream(MapPath(@"../App_Data/" + "tournee_" + Session["User"] + ".xml" ), System.IO.FileMode.Create), System.Text.Encoding.Unicode);
  3. tournee.WriteXml(myXmlWriter);
  4. myXmlWriter.Close();
  5. /*Création d'un fileinfo pour connaitre la taille du fichier*/
  6. FileInfo myFile = new FileInfo(MapPath(@"../App_Data/" + "tournee_" + Session["User"] + ".xml" ));
  7. /*download du fichier*/
  8. Response.Clear();
  9. Response.ContentType = "application/xml";
  10. Response.AppendHeader("Content-Disposition", "attachment; filename= tournee.xml" );
  11. Response.WriteFile(MapPath(@"../App_Data/" + "tournee_" + Session["User"] + ".xml" ));
  12. Response.AddHeader("Content-Length", myFile.Length.ToString());
  13. Response.End();


 
Voila le code que j'avais. Adapte le pour ton fichier excel, ça ne devrai tpas changer grand chose

n°1331812
Arjuna
Aircraft Ident.: F-MBSD
Posté le 24-03-2006 à 15:46:10  profilanswer
 

Voici mon code complet :
 
(affichage sous forme HTML, ou génération d'un fichier Excel, au choix)
 
-- code de kosovar inside --
 
Je génère un CSV par contre, because chez ce client il y a encore des gense sous Office 97 et Windows 95... Evidement, générer de l'XSL à partir d'un fichier HTML c'est pas possible...
Autre solution qui aurait été bien, c'est d'installer Excel sur le serveur, et générer "proprement" un vrai document XLS en utilisant le moteur d'Excel programmatiquement.
 
ProductList.aspx

Code :
  1. <%@ Page language="c#" Codebehind="ProductList.aspx.cs" AutoEventWireup="false" Inherits="bci.ProductList" %>
  2. <%@ Register TagPrefix="uc1" TagName="Banner" Src="Controls/Banner.ascx" %>
  3. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
  4. <HTML>
  5. <HEAD>
  6.  <title>Product List</title>
  7.  <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
  8.  <meta name="CODE_LANGUAGE" Content="C#">
  9.  <meta name="vs_defaultClientScript" content="JavaScript">
  10.  <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
  11.  <link href="medias/default.css" media="all" rel="stylesheet">
  12. </HEAD>
  13. <body MS_POSITIONING="GridLayout">
  14.  <form id="Form1" method="post" runat="server">
  15.   <asp:Label id="frm" Runat="server">
  16.   <uc1:Banner runat="server" ID="Banner1" NAME="Banner1"></uc1:Banner>
  17.   <table>
  18.    <tr>
  19.     <td><asp:Literal runat="server" ID="titProductCode" /></td>
  20.     <td><asp:TextBox id="txtCodpro" runat="server"></asp:TextBox></td>
  21.    </tr>
  22.    <tr>
  23.     <td><asp:Label id="txtFou" Runat="server"></asp:Label></td>
  24.     <td><asp:TextBox id="txtSigtie" runat="server"></asp:TextBox></td>
  25.    </tr>
  26.    <tr>
  27.     <td><asp:Literal runat="server" ID="titCollection" /></td>
  28.     <td><asp:TextBox id="txtSsfpro" runat="server"></asp:TextBox></td>
  29.    </tr>
  30.    <tr>
  31.     <td><asp:Literal runat="server" ID="titFurnitureType" /></td>
  32.     <td><asp:ListBox id="lstSfapro" Runat="server" Rows="1"></asp:ListBox></td>
  33.    </tr>
  34.    <tr>
  35.     <td><asp:Literal runat="server" ID="titWarehouse" /></td>
  36.     <td><asp:ListBox id="lstSigdep" Runat="server" Rows="1"></asp:ListBox></td>
  37.    </tr>
  38.    <tr>
  39.     <td colspan="2"><asp:Button ID="btnValidate" Runat="server"></asp:Button>&nbsp;<asp:Button ID="btnExcel" Runat="server"></asp:Button></td>
  40.    </tr>
  41.   </table>
  42.   <br/>
  43.   <br/>
  44.   </asp:Label>
  45.   <center>
  46.    <asp:Repeater ID="rptProducts" Runat="server">
  47.     <HeaderTemplate>
  48.      <table class="collectionList tableauListe" border="2" cellspacing="0" bordercolor="#660000"
  49.         bgcolor="#F5AC50">
  50.       <tr class="title">
  51.        <th>
  52.         <asp:Literal Runat="server" ID="titProduct" /></th>
  53.        <th>
  54.         <asp:Label ID="titleSigfou" Runat="server"></asp:Label>
  55.        </th>
  56.        <th>
  57.         <asp:Label id="titleNomfou" Runat="server"></asp:Label>
  58.        </th>
  59.        <th>
  60.         <asp:Literal Runat="server" ID="titWarehouse2" /></th>
  61.        <th>
  62.         <asp:Literal Runat="server" ID="titCollection2" /></th>
  63.        <th>
  64.         <asp:Literal Runat="server" ID="titFurnitureType2" /></th>
  65.        <th>
  66.         <asp:Literal Runat="server" ID="titDesignation" /></th>
  67.        <th>
  68.         <asp:Literal Runat="server" ID="titFinalStock" /></th>
  69.        <th>
  70.         <asp:Literal Runat="server" ID="titPhysicalStock" /></th>
  71.        <th>
  72.         <asp:Literal Runat="server" ID="titReservedStock" /></th>
  73.        <th>
  74.         <asp:Literal Runat="server" ID="titPreparationStock" /></th>
  75.        <th>
  76.         <asp:Literal Runat="server" ID="titStatus" /></th>
  77.        <th>
  78.         <asp:Label ID="titleVtar" Runat="server"></asp:Label>
  79.        </th>
  80.        <th>
  81.         <asp:Label ID="titleAtar" Runat="server"></asp:Label>
  82.        </th>
  83.        <th>
  84.         <asp:Label ID="titleRtar" Runat="server"></asp:Label>
  85.        </th>
  86.       </tr>
  87.     </HeaderTemplate>
  88.     <ItemTemplate>
  89.      <tr class="even">
  90.       <td><%# DataBinder.Eval(Container.DataItem, "codpro" ) %></td>
  91.       <td><asp:Label ID="valSigfou" Runat="server"></asp:Label></td>
  92.       <td><asp:Label ID="valNomfou" Runat="server"></asp:Label></td>
  93.       <td><%# DataBinder.Eval(Container.DataItem, "sigdep" ) %></td>
  94.       <td><%# DataBinder.Eval(Container.DataItem, "libfam1" ) %></td>
  95.       <td><%# DataBinder.Eval(Container.DataItem, "libfam2" ) %></td>
  96.       <td><%# DataBinder.Eval(Container.DataItem, "design1" ) %></td>
  97.       <td class="typeNumber"><%# DataBinder.Eval(Container.DataItem, "stk" ) %></td>
  98.       <td class="typeNumber"><%# DataBinder.Eval(Container.DataItem, "phy" ) %></td>
  99.       <td class="typeNumber"><%# DataBinder.Eval(Container.DataItem, "resa" ) %></td>
  100.       <td class="typeNumber"><%# DataBinder.Eval(Container.DataItem, "prepa" ) %></td>
  101.       <td><%# DataBinder.Eval(Container.DataItem, "codblocage" ) %></td>
  102.       <td class="typeNumber"><asp:Label id="valVtar" Runat="server"></asp:Label></td>
  103.       <td class="typeNumber"><asp:Label id="valAtar" Runat="server"></asp:Label></td>
  104.       <td class="typeNumber"><asp:Label id="valRtar" Runat="server"></asp:Label></td>
  105.      </tr>
  106.     </ItemTemplate>
  107.     <FooterTemplate>
  108.      </table>
  109.     </FooterTemplate>
  110.    </asp:Repeater>
  111.   </center>
  112.  </form>
  113. </body>
  114. </HTML>


 
ProductList.aspx.cs

Code :
  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Web;
  7. using System.Web.SessionState;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.HtmlControls;
  11. namespace bci
  12. {
  13. /// <summary>
  14. /// Summary description for ProductList.
  15. /// </summary>
  16. public class ProductList : System.Web.UI.Page
  17. {
  18.  protected System.Web.UI.WebControls.TextBox txtCodpro;
  19.  protected System.Web.UI.WebControls.TextBox txtSigtie;
  20.  protected System.Web.UI.WebControls.TextBox txtSsfpro;
  21.  protected System.Web.UI.WebControls.ListBox lstSfapro;
  22.  protected System.Web.UI.WebControls.ListBox lstSigdep;
  23.  protected System.Web.UI.WebControls.TextBox txtSfapro;
  24.  protected System.Web.UI.WebControls.TextBox txtSigdep;
  25.  protected System.Web.UI.WebControls.Label txtFou;
  26.  protected System.Web.UI.WebControls.Label frm;
  27.  protected Label titleSigfou;
  28.  protected Label titleNomfou;
  29.  protected Label titleVtar;
  30.  protected Label titleAtar;
  31.  protected Label titleRtar;
  32.  protected Literal titProductCode;
  33.  protected Literal titCollection;
  34.  protected Literal titFurnitureType;
  35.  protected Literal titWarehouse;
  36.  protected System.Web.UI.WebControls.Repeater rptProducts;
  37.  protected System.Web.UI.WebControls.Button btnValidate;
  38.  protected System.Web.UI.WebControls.Button btnExcel;
  39.  private Queries commander;
  40.  private language lan;
  41.  private void Page_Load(object sender, System.EventArgs e)
  42.  {
  43.   if (Session.Count == 0 || Session["login"] == null || Session["typtie"] == null || Session["codsoc"] == null)
  44.   {
  45.    Session.Clear();
  46.    Response.Redirect("Default.aspx", true);
  47.   }
  48.   commander = new Queries(string.Format((string) Application["cnxString"], (string) Application["dbLogin"], (string) Application["dbPass"], (string) Application["dbTNS"]));
  49.   lan = new language((string)Session["codlan"], Server.MapPath("." ));
  50.   titProductCode.Text = lan.GetMessage("titProductCode" );
  51.   txtFou.Text = lan.GetMessage("titSupplier" );
  52.   titCollection.Text = lan.GetMessage("titCollection" );
  53.   titFurnitureType.Text = lan.GetMessage("titFurnitureType" );
  54.   titWarehouse.Text = lan.GetMessage("titWarehouse" );
  55.   btnValidate.Text = lan.GetMessage("btnValidate" );
  56.   btnExcel.Text = lan.GetMessage("btnExcel" );
  57.   if (!(
  58.    habilitation.getHabilitation((string)Session["habilitation"], habilitation.Habilitations.supplier) &&
  59.    habilitation.getHabilitation((string)Session["habilitation"], habilitation.Habilitations.vtar) &&
  60.    habilitation.getHabilitation((string)Session["habilitation"], habilitation.Habilitations.atar) &&
  61.    habilitation.getHabilitation((string)Session["habilitation"], habilitation.Habilitations.rtar)
  62.    ))
  63.   {
  64.    btnExcel.Visible = false;
  65.   }
  66.   if (Page.IsPostBack)
  67.   {
  68.    if (Request.Form["btnExcel"] != null)
  69.    {
  70.     Response.Clear();
  71.     Response.ContentType = "text/csv";
  72.     Response.ContentEncoding = System.Text.Encoding.ASCII;
  73.     Response.AddHeader("Content-Disposition", "attachement; filename=\"resultat.csv\"" );
  74.     Response.Write("Produit,Sigle,Fournisseur,Depot,Collection,Type de mobilier,Designation,A terme,Physique,Reserve,Preparation,Etat,Prix de vente,Monnaie,Prix d'achat,Monnaie,Prix de revient,Monnaie\n" );
  75.     DataTable dt = commander.LoadProductList((decimal) Session["codsoc"], txtCodpro.Text, txtSigtie.Text, txtSsfpro.Text, lstSfapro.SelectedValue, lstSigdep.SelectedValue);
  76.     for (int i = 0; i < dt.Rows.Count; i++)
  77.     {
  78.      for (int j = 0; j < dt.Columns.Count; j++)
  79.      {
  80.       Response.Write("\"" + dt.Rows[i].ItemArray[j] + "\"" );
  81.       if (j == dt.Columns.Count - 1)
  82.       {
  83.        Response.Write("\n" );
  84.       }
  85.       else
  86.       {
  87.        Response.Write("," );
  88.       }
  89.      }
  90.     }
  91.     commander.webLog(Session["codsoc"], Session["typtie"], Session["login"], Request.ServerVariables["http_host"], Request.FilePath, Session["sigdep"], Session["codpro"]);
  92.     Response.End();
  93.    }
  94.    else
  95.    {
  96.     Click();
  97.    }
  98.   }
  99.   else
  100.   {
  101.    InitPage();
  102.   }
  103.   commander.webLog(Session["codsoc"], Session["typtie"], Session["login"], Request.ServerVariables["http_host"], Request.FilePath, Session["sigdep"], Session["codpro"]);
  104.  }
  105.  public void InitPage()
  106.  {
  107.   // Check connection to Generix is available
  108.   if (commander.RunTestQuery() && Session["login"] != null && Session["password"] != null)
  109.   {
  110.    DataTable dt = commander.LoadTypeMobilier((decimal) Session["codsoc"], true);
  111.    lstSfapro.Items.Clear();
  112.    if (dt.Rows.Count > 0)
  113.    {
  114.     lstSfapro.DataSource = dt;
  115.     lstSfapro.DataTextField = "libfam";
  116.     lstSfapro.DataValueField = "codesfa";
  117.     lstSfapro.DataBind();
  118.    }
  119.    DataTable dt2 = commander.LoadWarehouse((decimal) Session["codsoc"], true);
  120.    lstSigdep.Items.Clear();
  121.    if (dt2.Rows.Count > 0)
  122.    {
  123.     lstSigdep.DataSource = dt2;
  124.     lstSigdep.DataTextField = "nomtie";
  125.     lstSigdep.DataValueField = "sigtie";
  126.     lstSigdep.DataBind();
  127.    }
  128.    if (habilitation.getHabilitation((string)Session["habilitation"], habilitation.Habilitations.supplier))
  129.    {
  130.     txtFou.Visible = true;
  131.     txtSigtie.Visible = true;
  132.    }
  133.    else
  134.    {
  135.     txtFou.Visible = false;
  136.     txtSigtie.Visible = false;
  137.    }
  138.   }
  139.  }
  140.  private void Page_Unload(object sender, System.EventArgs e)
  141.  {
  142.   lan = null;
  143.   try{commander.Close();}
  144.   catch {};
  145.   commander = null;
  146.  }
  147.  protected void Click()
  148.  {
  149.   DataTable dt = commander.LoadProductList((decimal) Session["codsoc"], txtCodpro.Text, txtSigtie.Text, txtSsfpro.Text, lstSfapro.SelectedValue, lstSigdep.SelectedValue);
  150.   rptProducts.DataSource = dt;
  151.   rptProducts.DataBind();
  152.  }
  153.  private void rptProducts_ItemDataBound(object sender, RepeaterItemEventArgs e)
  154.  {
  155.   if(e.Item.ItemType == ListItemType.Header)
  156.   {
  157.    ((Literal)e.Item.FindControl("titProduct" )).Text = lan.GetMessage("titProduct" );
  158.    ((Label)e.Item.FindControl("titleSigfou" )).Text = lan.GetMessage("titleSigfou" );
  159.    ((Label)e.Item.FindControl("titleNomfou" )).Text = lan.GetMessage("titleNomfou" );
  160.    ((Literal)e.Item.FindControl("titWarehouse2" )).Text = lan.GetMessage("titWarehouse" );
  161.    ((Literal)e.Item.FindControl("titCollection2" )).Text = lan.GetMessage("titCollection" );
  162.    ((Literal)e.Item.FindControl("titFurnitureType2" )).Text = lan.GetMessage("titFurnitureType" );
  163.    ((Literal)e.Item.FindControl("titDesignation" )).Text = lan.GetMessage("titDesignation" );
  164.    ((Literal)e.Item.FindControl("titFinalStock" )).Text = lan.GetMessage("titFinalStock" );
  165.    ((Literal)e.Item.FindControl("titPhysicalStock" )).Text = lan.GetMessage("titPhysicalStock" );
  166.    ((Literal)e.Item.FindControl("titReservedStock" )).Text = lan.GetMessage("titReservedStock" );
  167.    ((Literal)e.Item.FindControl("titPreparationStock" )).Text = lan.GetMessage("titPreparationStock" );
  168.    ((Literal)e.Item.FindControl("titStatus" )).Text = lan.GetMessage("titStatus" );
  169.    ((Label)e.Item.FindControl("titleVtar" )).Text = lan.GetMessage("titleVtar" );
  170.    ((Label)e.Item.FindControl("titleAtar" )).Text = lan.GetMessage("titleAtar" );
  171.    ((Label)e.Item.FindControl("titleRtar" )).Text = lan.GetMessage("titleRtar" );
  172.    if (habilitation.getHabilitation((string)Session["habilitation"], habilitation.Habilitations.supplier))
  173.    {
  174.     ((Label)e.Item.FindControl("titleSigfou" )).Visible = true;
  175.     ((Label)e.Item.FindControl("titleNomfou" )).Visible = true;
  176.    }
  177.    else
  178.    {
  179.     ((Label)e.Item.FindControl("titleSigfou" )).Visible = false;
  180.     ((Label)e.Item.FindControl("titleNomfou" )).Visible = false;
  181.    }
  182.    if (habilitation.getHabilitation((string)Session["habilitation"], habilitation.Habilitations.vtar))
  183.    {
  184.     ((Label)e.Item.FindControl("titleVtar" )).Visible = true;
  185.    }
  186.    else
  187.    {
  188.     ((Label)e.Item.FindControl("titleVtar" )).Visible = false;
  189.    }
  190.    if (habilitation.getHabilitation((string)Session["habilitation"], habilitation.Habilitations.atar))
  191.    {
  192.     ((Label)e.Item.FindControl("titleAtar" )).Visible = true;
  193.    }
  194.    else
  195.    {
  196.     ((Label)e.Item.FindControl("titleAtar" )).Visible = false;
  197.    }
  198.    if (habilitation.getHabilitation((string)Session["habilitation"], habilitation.Habilitations.rtar))
  199.    {
  200.     ((Label)e.Item.FindControl("titleRtar" )).Visible = true;
  201.    }
  202.    else
  203.    {
  204.     ((Label)e.Item.FindControl("titleRtar" )).Visible = false;
  205.    }
  206.   }
  207.   if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
  208.   {
  209.    DataRowView dr = ((DataRowView) e.Item.DataItem);
  210.    if (habilitation.getHabilitation((string)Session["habilitation"], habilitation.Habilitations.supplier))
  211.    {
  212.     ((Label)e.Item.FindControl("valSigfou" )).Text = (string)dr["sigtie"];
  213.     ((Label)e.Item.FindControl("valNomfou" )).Text = (string)dr["nomtie"];
  214.    }
  215.    else
  216.    {
  217.     ((Label)e.Item.FindControl("valSigfou" )).Text = "";
  218.     ((Label)e.Item.FindControl("valNomfou" )).Text = "";
  219.    }
  220.    if (habilitation.getHabilitation((string)Session["habilitation"], habilitation.Habilitations.vtar))
  221.    {
  222.     if (dr != null)
  223.     {
  224.      ((Label)e.Item.FindControl("valVtar" )).Text = (string)dr["vtar"] + "&nbsp;" + ToolBox.CoddevToSymbol((string)dr["coddevv"]);
  225.     }
  226.     else
  227.     {
  228.      ((Label)e.Item.FindControl("valVtar" )).Text = "-";
  229.     }
  230.    }
  231.    else
  232.    {
  233.     ((Label)e.Item.FindControl("valVtar" )).Text = "";
  234.    }
  235.    if (habilitation.getHabilitation((string)Session["habilitation"], habilitation.Habilitations.atar))
  236.    {
  237.     if (dr != null)
  238.     {
  239.      ((Label)e.Item.FindControl("valAtar" )).Text = (string)dr["atar"] + "&nbsp;" + ToolBox.CoddevToSymbol((string)dr["coddeva"]);
  240.     }
  241.     else
  242.     {
  243.      ((Label)e.Item.FindControl("valAtar" )).Text = "-";
  244.     }
  245.    }
  246.    else
  247.    {
  248.     ((Label)e.Item.FindControl("valAtar" )).Text = "";
  249.    }
  250.    if (habilitation.getHabilitation((string)Session["habilitation"], habilitation.Habilitations.rtar))
  251.    {
  252.     if (dr != null)
  253.     {
  254.      ((Label)e.Item.FindControl("valRtar" )).Text = (string)dr["rev"] + "&nbsp;" + ToolBox.CoddevToSymbol((string)dr["coddevr"]);
  255.     }
  256.     else
  257.     {
  258.      ((Label)e.Item.FindControl("valRtar" )).Text = "-";
  259.     }
  260.    }
  261.    else
  262.    {
  263.     ((Label)e.Item.FindControl("valRtar" )).Text = "";
  264.    }
  265.   }
  266.  }
  267.  #region Web Form Designer generated code
  268.  override protected void OnInit(EventArgs e)
  269.  {
  270.   //
  271.   // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  272.   //
  273.   InitializeComponent();
  274.   base.OnInit(e);
  275.  }
  276.  /// <summary>
  277.  /// Required method for Designer support - do not modify
  278.  /// the contents of this method with the code editor.
  279.  /// </summary>
  280.  private void InitializeComponent()
  281.  {   
  282.   this.Unload += new System.EventHandler(this.Page_Unload);
  283.   this.Load += new System.EventHandler(this.Page_Load);
  284.   this.rptProducts.ItemDataBound += new System.Web.UI.WebControls.RepeaterItemEventHandler(this.rptProducts_ItemDataBound);
  285.  }
  286.  #endregion
  287. }
  288. }

n°1333691
the big be​n
Posté le 28-03-2006 à 14:37:32  profilanswer
 

ca fonctionne bien pour le téléchargement mais il me met toujours des crasses après la taille de mon fichier pourtant j'ai meme essayer de mettre mon Response.AddHeader('Content-Length', '10'); mais ca n'a pas l'air de changer quoi que se soit...

n°1334008
moi23372
Posté le 28-03-2006 à 19:39:28  profilanswer
 

oui j'ai eu ce problème la aussi avec les crasses. Tu as bien fait comme dans mon exemple plus haut? me rappele que c'était très subtile comme problème

n°1334379
the big be​n
Posté le 29-03-2006 à 10:05:02  profilanswer
 

oui j'ai essayé comme dans ton exmple mais j'ai pas trouvé la subltilité :(
Ceci dit j'ai résolu mon problème en passant par un page saveAs et en la refermant juste après c'est moche mais bon ca dépanne! ceci dit si tu trouve LA solution je suis encore preneur!

n°1334510
Arjuna
Aircraft Ident.: F-MBSD
Posté le 29-03-2006 à 12:17:05  profilanswer
 

Ma solution te plaît pas ?
Pourtant moi j'ai pas de crasses dans mon fichier...


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C#/.NET managed

  ASP.NET SaveAs

 

Sujets relatifs
[ASP.NET] Dropdownlist avec text limitéEquivalent des WebParts 2.0 de .NET ??
Tableaux VB.Net et déclenchement d'évenementsprogrammation en .NET
[ASP]Probleme fonctionnement moteur de recherche[Débutant] [VB.NET] Insertion image à partir d'une datagridv
[C#] ASP.NET > Localization, ressources etc... Tuto ?[VB.NET/VB] Probleme image dans une form !!
Plus de sujets relatifs à : ASP.NET SaveAs


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR