return string[] from PageMethod + click on the row + div !?

Last post 04-30-2008 10:02 AM by kim3er. 1 replies.

Sort Posts:

  • return string[] from PageMethod + click on the row + div !?

    04-30-2008, 5:15 AM

    Hi,

     I work with visual studio 05 + ajax but WITHOUT ajax toolkit!

    I have a pageMetod who call a store procedure (select top (5) .. from table where name = @param) with a parameter and return an arrayList.

    On my javascript, i well receive the arrayList.

    Here is it my OnSucceeded method who receive my arraylist

    //Succeed

    function OnSucceeded(result){

     

    var data = result;

    var nbre = result.length;var chaine ='';

     

    if(nbre != 0)

    {

    chaine =
    '<h2>- Result :' + nbre + ' -</h2>';

     

    for (i = 0; i < data.length; i++)

    {

    chaine = chaine + data[i] + "<br/>";

    }

     

    }

    Well, now i'd like to put a onclick for all return value and when i click on the row i want to display the value in a alert but i don't know how to do this !?

    How i can add a onclick on a return value ?

    Thanks

    Christophe

  • Re: return string[] from PageMethod + click on the row + div !?

    04-30-2008, 10:02 AM
    Answer
    • Loading...
    • kim3er
    • Joined on 04-30-2008, 6:29 AM
    • West Yorkshire, UK
    • Posts 10
    Hi,

    Firstly, I wouldn't build the elements in a string. Build your elements using DOM (i.e. document.createElement), this will allow you to attach handlers to your events using $addHandler.

    You could do something like:
    var message = 'hello';
    var div = document.createElement('div');
    div.id= 'test_div';
    $addHandler(div, 'click', function(evt) { alert(message); });
    document.body.appendChild(div);
    
    Rich
    Filed under: , ,
Page 1 of 1 (2 items)
Microsoft Communities
Page view counter