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

AJAX Discussion :

[AJAX] [JS/ASP.NET] Récupérer un tableau dynamique !


Sujet :

AJAX

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Inscrit en
    Décembre 2008
    Messages
    280
    Détails du profil
    Informations forums :
    Inscription : Décembre 2008
    Messages : 280
    Par défaut [AJAX] [JS/ASP.NET] Récupérer un tableau dynamique !
    Bonjour, je suis face a un problème ...

    J'ai donc 3 pages :

    listing.aspx :
    la page de base qui a juste une div vide et appelle ma fonction javascript au chargement de la page.
    ajax_listing.js : Contient le javascript qui va remplir ma div en fonction d'une autre page.
    aff_listing.aspx : Crée mon tableau dynamiquement

    ajax_listing.js
    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
     
     //<script language="javascript" type="text/javascript">
       var xhr = null;
     
    // Fonction de creation de l'objet XMLHttpRequest qui resservira pour chaques fonctions AJAX
    function getXhr()
     {
      if(window.XMLHttpRequest) xhr = new XMLHttpRequest(); 
      else if(window.ActiveXObject)
       {  
        try
         {
            xhr = new ActiveXObject("Microsoft.XMLHTTP");
         }
        catch (e)
         {
     
          xhr = new ActiveXObject("Msxml2.XMLHTTP");
         }
       }
      else 
       { 
        alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest, veuillez le mettre à jour"); 
        xhr = false; 
       } 
     }
     
        function next(nbr_debut, id)
        {
         getXhr();
         xhr.open("POST","../aff_listing.aspx?ID="+id,true);
      xhr.onreadystatechange = function()
       {
        if(xhr.readyState == 4 )//&& xhr.status == 200)
         {
          // Nous remplacons le contenu du div iris par le retour de "ajax/ajaxiris.php"
         //nbr_debut = nbr_debut + 10
         //alert(xhr.responseText);
         var test;
         test = xhr.responsetext;
         document.getElementById("div_test").innerhtml = test
         }
       }
     
      xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
      var data = 'nbr_debut='+nbr_debut;
      xhr.send(data);
     }
     
     
     
        //</script>
    aff_listing.aspx
    Ici je ne vais pas copier tout le code mais faire un tout petit tableau ce qui reviendra au même.
    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
     
    Public function Page_load()
    dim str_table as string
    str_table = listing()
     
    return str_table //ici je retourne donc ceci a mon javascrip !
    end function
     
    public function listing()
    dim table as table
    dim row as tablerow
    dim cell as tablecell
    dim table = new table
    dim row = new tablerow
    dim cell = new tablecell
     
    row.controls.add(cell)
    table.controls.add(row)
     
    //Ici je ne sais pas en quoi convertir ce tableau afin de le faire pssé en javascript et l'afficher dans la div.
    //J'ai donc essayé un convert.tostring
    dim test as string
    test = convert.tostring(table)
    return test
    end function
    Donc mon problème c'est que rien ne s'affiche dans ma DIV !


    Voilà si vous voulez plus de précision hésitez pas a demander !

    Merci

  2. #2
    Rédacteur

    Avatar de Bovino
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Billets dans le blog
    20
    Par défaut
    Salut,
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    test = xhr.responsetext;
    JavaScript est sensible à la casse, la bonne syntaxe est :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    test = xhr.responseText;
    Pas de question technique par MP !
    Tout le monde peut participer à developpez.com, vous avez une idée, contactez-moi !
    Mes formations video2brain : La formation complète sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
    Mon livre sur jQuery
    Module Firefox / Chrome d'intégration de JSFiddle et CodePen sur le forum

  3. #3
    Membre éclairé
    Inscrit en
    Décembre 2008
    Messages
    280
    Détails du profil
    Informations forums :
    Inscription : Décembre 2008
    Messages : 280
    Par défaut
    Merci de la précision même si c'était bien écrit dans mon code. Ducoup après debuggage la var test vaut :

    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
     
    <html>
        <head>
            <title>Not Found</title>
            <style>
            	body {font-family:"Verdana";font-weight:normal;font-size: 8pt;color:black;} 
            	p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
            	b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
            	h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
            	h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
            	pre {font-family:"Lucida Console";font-size: 8pt}
            	.marker {font-weight: bold; color: black;text-decoration: none;}
            	.version {color: gray;}
            	.error {margin-bottom: 10px;}
            	.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
            </style>
        </head>
        <body bgcolor="white">
     
                <span><h1>Server Error in '/kitweb' Application.<hr width=100% size=1 color=silver></h1>
     
                <h2> <i>HTTP Error 404 - Not Found.</i> </h2></span>
     
                <hr width=100% size=1 color=silver>
     
                <b>Version Information:</b>&nbsp;ASP.NET Development Server 9.0.0.0
     
                </font>
     
        </body>
    </html>
    Moi je voudrais un truc du genre :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <Table> avec les ligne etc </Table>

  4. #4
    Rédacteur

    Avatar de Bovino
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Billets dans le blog
    20
    Par défaut
    Ben là il te renvoie une erreur 404 !
    L'URL appelée est mauvaise
    Pas de question technique par MP !
    Tout le monde peut participer à developpez.com, vous avez une idée, contactez-moi !
    Mes formations video2brain : La formation complète sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
    Mon livre sur jQuery
    Module Firefox / Chrome d'intégration de JSFiddle et CodePen sur le forum

  5. #5
    Membre éclairé
    Inscrit en
    Décembre 2008
    Messages
    280
    Détails du profil
    Informations forums :
    Inscription : Décembre 2008
    Messages : 280
    Par défaut
    Ok merci de ta réponse, donc après correction ma var test vaut :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    A savoir que dans aff_listing.aspx (partie Source), j'ai juste le header (donc ce qu'il y a dans var test.

    Comment je peux récupéré le tableau construit en code behind ?!

    Merci

  6. #6
    Membre éclairé
    Inscrit en
    Décembre 2008
    Messages
    280
    Détails du profil
    Informations forums :
    Inscription : Décembre 2008
    Messages : 280
    Par défaut
    Bon après quelque bidouillage, je reçois dans ma var test ceci :

    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
     
    <!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 id="Head1"><title>
    	Untitled Page
    </title></head>
    <body>
        <form name="form1" method="post" action="aff_listing.aspx?ID=1" id="form1">
    <div>
    <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJOTYwNDQwMTE3ZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WCgUFY3RsMDIFBWN0bDA0BQVjdGwwNgUFY3RsMDgFBWN0bDEwBQVjdGwxMgUFY3RsMTQFBWN0bDE2BQVjdGwxOAUFY3RsMjBOFyUFo3xonsDrOYGeGbbkxuy6eg==" />
    </div>
     
    <div>
     
    	<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWFgLJi/WUCQKfwImNCwKgwImNCwKlwImNCwKmwImNCwKjwImNCwKkwImNCwKZwImNCwKawImNCwKhwPWxAgKiwPWxAgKfwPWxAgKgwPWxAgKlwPWxAgKmwPWxAgKjwPWxAgKkwPWxAgKZwPWxAgKawPWxAgKhwOHWCQKiwOHWCQKHtuzdD0ei2NbKBv7OmBMM45Ltkg/aRtIQ" />
    </div>
        <div id="test2">
     
        <table id="tab_listing" runat="Server" border="0">
    	<tr id="headrow" runat="server">
    		<th id="headcell_sel_mul" runat="server">Sélection Multiple</th><th id="headcell_ordre" runat="server">Ordre</th><th id="headcell1" runat="server">Date_Creation</th><th id="headcell2" runat="server">Titre</th>
    	</tr><tr id="row_listing0" runat="server">
    		<td id="cell_listing_sel_mul0" runat="server"><span id="cb_sel_mul0" runat="server"><input id="ctl02" type="checkbox" name="ctl02" /></span></td><td id="cell_listing_ordre0" runat="server"><input name="ctl03" type="text" value="11" id="tb_ordre0" runat="server" /></td><td id="cell_listing01" runat="server">13/10/2009 14:50:25</td><td id="cell_listing02" runat="server">Titre 11</td>
    	</tr><tr id="row_listing1" runat="server">
    		<td id="cell_listing_sel_mul1" runat="server"><span id="cb_sel_mul1" runat="server"><input id="ctl04" type="checkbox" name="ctl04" /></span></td><td id="cell_listing_ordre1" runat="server"><input name="ctl05" type="text" value="12" id="tb_ordre1" runat="server" /></td><td id="cell_listing11" runat="server">13/10/2009 14:50:25</td><td id="cell_listing12" runat="server">Titre 12</td>
    	</tr><tr id="row_listing2" runat="server">
    		<td id="cell_listing_sel_mul2" runat="server"><span id="cb_sel_mul2" runat="server"><input id="ctl06" type="checkbox" name="ctl06" /></span></td><td id="cell_listing_ordre2" runat="server"><input name="ctl07" type="text" value="9" id="tb_ordre2" runat="server" /></td><td id="cell_listing21" runat="server">12/10/2009 14:50:25</td><td id="cell_listing22" runat="server">Titre 9</td>
    	</tr><tr id="row_listing3" runat="server">
    		<td id="cell_listing_sel_mul3" runat="server"><span id="cb_sel_mul3" runat="server"><input id="ctl08" type="checkbox" name="ctl08" /></span></td><td id="cell_listing_ordre3" runat="server"><input name="ctl09" type="text" value="10" id="tb_ordre3" runat="server" /></td><td id="cell_listing31" runat="server">12/10/2009 14:50:25</td><td id="cell_listing32" runat="server">Titre 10</td>
    	</tr><tr id="row_listing4" runat="server">
    		<td id="cell_listing_sel_mul4" runat="server"><span id="cb_sel_mul4" runat="server"><input id="ctl10" type="checkbox" name="ctl10" /></span></td><td id="cell_listing_ordre4" runat="server"><input name="ctl11" type="text" value="6" id="tb_ordre4" runat="server" /></td><td id="cell_listing41" runat="server">11/10/2009 14:50:25</td><td id="cell_listing42" runat="server">Titre 6</td>
    	</tr><tr id="row_listing5" runat="server">
    		<td id="cell_listing_sel_mul5" runat="server"><span id="cb_sel_mul5" runat="server"><input id="ctl12" type="checkbox" name="ctl12" /></span></td><td id="cell_listing_ordre5" runat="server"><input name="ctl13" type="text" value="7" id="tb_ordre5" runat="server" /></td><td id="cell_listing51" runat="server">11/10/2009 14:50:25</td><td id="cell_listing52" runat="server">Titre 7</td>
    	</tr><tr id="row_listing6" runat="server">
    		<td id="cell_listing_sel_mul6" runat="server"><span id="cb_sel_mul6" runat="server"><input id="ctl14" type="checkbox" name="ctl14" /></span></td><td id="cell_listing_ordre6" runat="server"><input name="ctl15" type="text" value="8" id="tb_ordre6" runat="server" /></td><td id="cell_listing61" runat="server">11/10/2009 14:50:25</td><td id="cell_listing62" runat="server">Titre 8</td>
    	</tr><tr id="row_listing7" runat="server">
    		<td id="cell_listing_sel_mul7" runat="server"><span id="cb_sel_mul7" runat="server"><input id="ctl16" type="checkbox" name="ctl16" /></span></td><td id="cell_listing_ordre7" runat="server"><input name="ctl17" type="text" value="5" id="tb_ordre7" runat="server" /></td><td id="cell_listing71" runat="server">11/10/2009 13:50:25</td><td id="cell_listing72" runat="server">Titre 5</td>
    	</tr><tr id="row_listing8" runat="server">
    		<td id="cell_listing_sel_mul8" runat="server"><span id="cb_sel_mul8" runat="server"><input id="ctl18" type="checkbox" name="ctl18" /></span></td><td id="cell_listing_ordre8" runat="server"><input name="ctl19" type="text" value="4" id="tb_ordre8" runat="server" /></td><td id="cell_listing81" runat="server">11/10/2009 13:50:25</td><td id="cell_listing82" runat="server">Titre 4</td>
    	</tr><tr id="row_listing9" runat="server">
    		<td id="cell_listing_sel_mul9" runat="server"><span id="cb_sel_mul9" runat="server"><input id="ctl20" type="checkbox" name="ctl20" /></span></td><td id="cell_listing_ordre9" runat="server"><input name="ctl21" type="text" value="3" id="tb_ordre9" runat="server" /></td><td id="cell_listing91" runat="server">11/10/2009 12:50:25</td><td id="cell_listing92" runat="server">Titre 3</td>
    	</tr><tr id="footrow" runat="server">
    		<td id="footcell0"></td><td id="footcell1" runat="server"><input type="submit" name="btn_suivant" value=">" onclick="javascript:next(0,1);" id="btn_suivant" runat="server" /></td>
    	</tr>
    </table></div>
        </form>
    </body>
    </html>
    Donc mon tableau est présent dans tous ça, mais il ne s'affiche pas !
    Y a-t-il un moyen de récupéré que mon tableau et de l'injecter ?
    Ou est-ce qu'il faut que j'ai dans ma var test que mon tableau ? si oui, comment je dois m'y prendre ?

    EDIT : j'ai remarquer que j'avais mi innerhtm sans majuscule, donc maintenant le contenu s'ajoute mais il me fait une ... erreur inconnue lol.

    je pense que c'est parce que dans var test j'ai tout le contenu de ma page !

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 1
    Dernier message: 03/04/2007, 21h27
  2. [1.1][vb.net] création de tableau dynamique
    Par elastoplas dans le forum ASP.NET
    Réponses: 3
    Dernier message: 01/12/2006, 09h44
  3. [AJAX] Ajax et ASP.NET
    Par boleduch dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 02/03/2006, 16h15
  4. [CR9] [D2005] [ASP.NET WEB App] Création dynamique d'un état
    Par Crystalou dans le forum SAP Crystal Reports
    Réponses: 5
    Dernier message: 09/03/2005, 09h21

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