IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ASP.NET Discussion :

Passage de Paramètres


Sujet :

ASP.NET

  1. #1
    Membre averti
    Inscrit en
    Juillet 2007
    Messages
    52
    Détails du profil
    Informations forums :
    Inscription : Juillet 2007
    Messages : 52
    Par défaut Passage de Paramètres
    Salut

    Voila j'ai un page (aspx) qui contient la liste des fichiers xml.
    (passage de paramètre à partir d'un fichier xsl)
    Quand je click sur un fichier ça m'ouvre une autre page(aspx).
    Mais je n'arrive à lui faire ouvrir le fichier xml correspondant et l'afficher dans la page aspx (grâce à un fichier xsl).


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    
     protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
    //je récupère la valeur passer en paramètre:fichier
                string fichierRSS = this.Request.QueryString["fichier"];
                
                XmlDocument doc = new XmlDocument();
    //problème à ce niveau :(      
           doc.Load(Server.MapPath(fichierRSS));
    
          
    
                 XslTransform xslt = new XslTransform();
                xslt.Load(Server.MapPath("affich_lien_RSS.xsl"));
    
                string xmlQuery = "//item";
                XmlNodeList nodeList = doc.DocumentElement.LastChild.SelectNodes(xmlQuery);
    
    
                MemoryStream ms = new MemoryStream();
                xslt.Transform(doc, null, ms);
                ms.Seek(0, SeekOrigin.Begin);
    
                StreamReader sr = new StreamReader(ms);
    
                Response.Write(sr.ReadToEnd());
                 
    
        }

  2. #2
    Rédacteur
    Avatar de SaumonAgile
    Homme Profil pro
    Team leader
    Inscrit en
    Avril 2007
    Messages
    4 028
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Team leader
    Secteur : Conseil

    Informations forums :
    Inscription : Avril 2007
    Messages : 4 028
    Par défaut
    Et quel est le problème ? Exception ? Si oui laquelle ?
    Merci de donner des détails et d'éviter les "ça ne marche pas" ou "il y a un problème", car pour nous ça ne veut rien dire, nous ne sommes pas derrière ton écran.
    Besoin d'un MessageBox amélioré ? InformationBox pour .NET 1.1, 2.0, 3.0, 3.5, 4.0 sous license Apache 2.0.

    Bonnes pratiques pour les accès aux données
    Débogage efficace en .NET
    LINQ to Objects : l'envers du décor

    Mon profil LinkedIn - MCT - MCPD WinForms - MCTS Applications Distribuées - MCTS WCF - MCTS WCF 4.0 - MCTS SQL Server 2008, Database Development - Mon blog - Twitter

  3. #3
    Membre averti
    Inscrit en
    Juillet 2007
    Messages
    52
    Détails du profil
    Informations forums :
    Inscription : Juillet 2007
    Messages : 52
    Par défaut
    Pour le dernier message c'est bon.
    Maintenant j'ai un autre problème.

    J'ai le fichier aspx avec les fichiers xml. En clickant sur un nom de fichier ça m'affichier bien un autre tableau dans la même avec les donnees du fichier xml.

    ex:
    Titre Lien Descript
    titi www blablabla
    toto http .....

    Maintenant je veux que quand je click sur titi, les données soient mis dans des textbox. (ça je sais le faire sans les Request.QueryString())


    Ben la mon probléme c'est comment gérer les Request.QueryString.


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
     
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.IO;
    using System.Xml.Xsl;
    using System.Xml;
     
     
    public partial class fluxPublier : System.Web.UI.Page
    {
     
        protected void Page_Load(object sender, EventArgs e)
        {
           if (!IsPostBack)
            {
                string fichierRSS = this.Request.QueryString["fichier"];
                fluxRSS = fichierRSS;
                Response.Write(fichierRSS);
                affich(sender, e, Request.QueryString["edit"],fichierRSS);
     
            }
     
        }
     
     
     
        protected void affich(object sender, EventArgs e, string title, string fichierRSS)
        {
     
     
            if (fichierRSS != null && title == null) //quand on a clicker sur un nom de fichier pour afficher le tableau qui va contenir les données du fichier.
            {
                string strpath = "C:/Documents and Settings/.../" + fichierRSS;
     
                XmlDocument doc = new XmlDocument();
                doc.Load(strpath);
     
                XslTransform xslt = new XslTransform();
                xslt.Load(Server.MapPath("affich_chq_fluxPublier.xsl"));
     
                string xmlQuery = "//item";
                XmlNodeList nodeList = doc.DocumentElement.LastChild.SelectNodes(xmlQuery);
     
     
                MemoryStream ms = new MemoryStream();
                xslt.Transform(doc, null, ms);
                ms.Seek(0, SeekOrigin.Begin);
     
                StreamReader sr = new StreamReader(ms);
     
                //Print out the result
                Response.Write(sr.ReadToEnd());
     
            }
     
    //une fois que le tableau est afficher  fichierRSS perd sa valeur  mais par contre title a une nouvelle valeur. 
    Comment faire pour garder la valeur de fichier quand le serveur recharge la page?
    En d'autres mots la valeur de fichierRSS ne doit jamais être à null
            else if (fichierRSS == null && title != null)
            {
     
     
               //affichage dans les textboxs (ok)
            }
     
     
        }
     
     
     
    }

  4. #4
    Membre averti
    Inscrit en
    Juillet 2007
    Messages
    52
    Détails du profil
    Informations forums :
    Inscription : Juillet 2007
    Messages : 52
    Par défaut
    Pour le dernier message c'est bon.
    Maintenant j'ai un autre problème.

    J'ai le fichier aspx avec les fichiers xml. En clickant sur un nom de fichier ça m'affichier bien un autre tableau dans la même avec les donnees du fichier xml.

    ex:
    Titre Lien Descript
    titi www blablabla
    toto http .....

    Maintenant je veux que quand je click sur titi, les données soient mis dans des textbox. (ça je sais le faire sans les Request.QueryString())


    Ben la mon probléme c'est comment gérer les Request.QueryString.


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.IO;
    using System.Xml.Xsl;
    using System.Xml;
    
    
    public partial class fluxPublier : System.Web.UI.Page
    {
       
        protected void Page_Load(object sender, EventArgs e)
        {
           if (!IsPostBack)
            {
                string fichierRSS = this.Request.QueryString["fichier"];
                Response.Write(fichierRSS);
                affich(sender, e, Request.QueryString["edit"],fichierRSS);
    
            }
    
        }
    
      
    
        protected void affich(object sender, EventArgs e, string title, string fichierRSS)
        {
    
    
            if (fichierRSS != null && title == null) //quand on a clicker sur un nom de fichier pour afficher le tableau qui va contenir les données du fichier. (ok)
            {
                string strpath = "C:/Documents and Settings/.../" + fichierRSS;
               
                XmlDocument doc = new XmlDocument();
                doc.Load(strpath);
    
                XslTransform xslt = new XslTransform();
                xslt.Load(Server.MapPath("affich_chq_fluxPublier.xsl"));
    
                string xmlQuery = "//item";
                XmlNodeList nodeList = doc.DocumentElement.LastChild.SelectNodes(xmlQuery);
    
    
                MemoryStream ms = new MemoryStream();
                xslt.Transform(doc, null, ms);
                ms.Seek(0, SeekOrigin.Begin);
    
                StreamReader sr = new StreamReader(ms);
    
                //Print out the result
                Response.Write(sr.ReadToEnd());
    
            }
    
    //une fois que le tableau est afficher  fichierRSS perd sa valeur  mais par contre title a une nouvelle valeur. 
    Comment faire pour garder la valeur de fichier quand le serveur recharge la page?
    En d'autres mots la valeur de fichierRSS ne doit jamais être à null        else if (fichierRSS == null && title != null)
            {
    
    
               //affichage dans les textboxs (ok)
            }
    
    
        }
    
    
       
    }

  5. #5
    Membre averti
    Inscrit en
    Juillet 2007
    Messages
    52
    Détails du profil
    Informations forums :
    Inscription : Juillet 2007
    Messages : 52
    Par défaut
    Je ne sais pas si vous m'avez bien compris. Voici tous les fichiers si vous voulez tester.

    fluxPublier.aspx
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
     
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="fluxPublier.aspx.cs" Inherits="fluxPublier" %>
     
    <!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>fluxPublier</title>
        </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Xml ID="Xml1" runat="server" DocumentSource="~/ListeFluxRSS.xml" TransformSource="~/fluxPublier.xsl"></asp:Xml></div>
     
     
     
     
            <br />
            <br />
     
            Title<asp:TextBox ID="textboxTitle" runat="server" Width="222px"></asp:TextBox>
            <br />
            Link<asp:TextBox ID="textboxLink" runat="server" Width="222px"></asp:TextBox><br />
            Copyright
           <asp:TextBox ID="textboxCopyright" runat="server" Width="222px"></asp:TextBox><br />
            Description
            <asp:TextBox ID="textboxDescription" runat="server" Width="222px"></asp:TextBox>
            &nbsp;
            <br />
            <br />
     
     
            &nbsp;&nbsp;<br /> 
            <br />
         <asp:Label id="Message" runat="server"/>
     
     
        </form>
    </body>
    </html>

    fluxPublier.aspx.cs
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
     
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.IO;
    using System.Xml.Xsl;
    using System.Xml;
     
     
    public partial class fluxPublier : System.Web.UI.Page
    {
     
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string fichierRSS = this.Request.QueryString["fichier"];
     
                Response.Write(fichierRSS);
                affich(sender, e, Request.QueryString["edit"], fichierRSS);
     
            }
     
        }
     
     
     
        protected void affich(object sender, EventArgs e, string title, string fichierRSS)
        {
            if (fichierRSS != null && title == null)
            {
                string strpath = "C:/Documents and Settings/.../" + fichierRSS;
     
                XmlDocument doc = new XmlDocument();
                doc.Load(strpath);
     
                XslTransform xslt = new XslTransform();
                xslt.Load(Server.MapPath("affich_chq_fluxPublier.xsl"));
     
                string xmlQuery = "//item";
                XmlNodeList nodeList = doc.DocumentElement.LastChild.SelectNodes(xmlQuery);
     
     
                MemoryStream ms = new MemoryStream();
                xslt.Transform(doc, null, ms);
                ms.Seek(0, SeekOrigin.Begin);
     
                StreamReader sr = new StreamReader(ms);
     
                //Print out the result
                Response.Write(sr.ReadToEnd());
     
            }
    /*  else //quand title est différent de null
            {
                // faudrait récupérer la valeur de fichierRSS !!!!!!!!!
        
            
             //affichage dans les textbox
     
                XmlNodeList lstitem = doc.SelectNodes("/rss/channel/item[title='" + title + "']");
     
                foreach (XmlNode node in lstitem)
                {
                  
                    XmlNodeList lstChildren = node.ChildNodes;
     
                    if (node.FirstChild.InnerText == title)
                    
                    {
                        textboxTitle.Text = node.FirstChild.InnerText;
     
     
                        foreach (XmlNode noeud in lstChildren)
                        {
                            if (noeud.Name == "link")
                                textboxLink.Text = noeud.InnerText;
     
                            if (noeud.Name == "copyright")
                                textboxCopyright.Text = noeud.InnerText;
     
                            if (noeud.Name == "description")
                                textboxDescription.Text = noeud.InnerText;
     
                        }
                    }
     
     
                }
            }*/
        }
    }

    ListeFluxRSS.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    <?xml version="1.0" encoding="utf-8"?>
    <fichiers>
      <flux>
        <nomFlux>fluxRSS1.xml</nomFlux>
        <title>W3Schools Home Page</title>
        <description>Free web building tutorials</description>
        <webmaster>titi@yahoo.fr</webmaster>
        <publier>oui</publier>
        <date_last_modif>19/07/2007 14:39:27</date_last_modif>
      </flux>
      <flux>
        <nomFlux>fluxRSS2.xml</nomFlux>
        <title>RSS Tutorial</title>
        <description>New RSS tutorial on W3Schools</description>
        <webmaster>tutu@yahoo.fr</webmaster>
        <publier>non</publier>
        <date_last_modif>19/07/2007 14:26:43</date_last_modif>
      </flux>
    </fichiers>
    fluxRSS1.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <?xml version="1.0" encoding="Windows-1252" standalone="yes"?>
    <rss version="2.0">
      <channel>
        <title>W3Schools Home Page</title>
        <link>http://www.w3schools.com</link>
        <description>Free web building tutorials</description>
        <webmaster>titi@yahoo.fr</webmaster>
      </channel>
    </rss>


    affich_chq_fluxPublier.xsl
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    <?xml version="1.0" encoding="utf-8"?>
     
    <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     
      <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" />
      <xsl:template match="/">
     
        <!--<html>
        <body>-->
        <h2>Liens RSS</h2>
        <table border="1">
     
          <tr>
            <th>Titre</th>
            <th>Lien</th>
            <th>Description</th>
          </tr>
          <xsl:for-each select="rss/channel">
            <tr>
              <td>
                [<A>
                  <xsl:attribute name="HREF">
                    fluxPublier.aspx?edit=<xsl:value-of select="title" />
                    <xsl:value-of select="id"/>
                  </xsl:attribute>
                  <xsl:value-of select="title" />
                </A>]
              </td>
              <td>
                <xsl:value-of select="link" />
              </td>
              <td>
                <xsl:value-of select="description"/>
              </td>
            </tr>
          </xsl:for-each>
     
     
     
          <xsl:for-each select="rss/channel/item">
            <tr>
              <td>
     
                [<A>
                  <xsl:attribute name="HREF">
                    fluxPublier.aspx?edit=<xsl:value-of select="title" />
                    <xsl:value-of select="id"/>
                  </xsl:attribute>
                  <xsl:value-of select="title" />
                </A>]
     
              </td>
              <td>
                <xsl:value-of select="link" />
              </td>
              <td>
                <xsl:value-of select="description"/>
              </td>
            </tr>
     
     
     
          </xsl:for-each>
     
     
        </table>
     
        <!--   </body>
      </html>-->
     
      </xsl:template>
     
    </xsl:stylesheet>

    fluxPublier.xsl
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    <?xml version="1.0" encoding="utf-8"?>
     
    <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     
    <xsl:template match="/">
      <h2>Flux Publier</h2>
      <table border="1">
        <tr>
        <th>Nom de Fichier</th>
          <th>Titre</th>
          <th>Description</th>
          <th>Webmaster</th>
        </tr>
     
        <xsl:for-each select="fichiers/flux">
          <xsl:if test="publier = 'oui'">
            <tr>
              <td>
                <A>
                  <xsl:attribute name="HREF">
                    fluxPublier.aspx?fichier=<xsl:value-of select="nomFlux"/>
                    <xsl:value-of select="id"/>
                  </xsl:attribute>
                  <xsl:value-of select="nomFlux"/>
                </A>
              </td>
              <td>
                <xsl:value-of select="title"/>
              </td>
              <td>
                <xsl:value-of select="description"/>
              </td>
              <td>
                <xsl:value-of select="webmaster"/>
              </td>
            </tr>
          </xsl:if>
          </xsl:for-each>
     
        </table>
      </xsl:template>
     
    </xsl:stylesheet>

Discussions similaires

  1. [Forms]Passage de paramètre entre Forms et Reports
    Par jack554 dans le forum Reports
    Réponses: 4
    Dernier message: 30/03/2004, 13h58
  2. probleme lors du passage de paramètre
    Par maxmj dans le forum ASP
    Réponses: 4
    Dernier message: 18/11/2003, 00h15
  3. [XSL] Passage de paramètres à un template
    Par pantin dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 27/06/2003, 13h28
  4. passage de paramètres
    Par pram dans le forum XMLRAD
    Réponses: 5
    Dernier message: 18/02/2003, 17h28
  5. passage en paramètre d'un array dynamique 2D
    Par Guigui_ dans le forum Langage
    Réponses: 4
    Dernier message: 27/11/2002, 19h47

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo