Generating client-side code from the server.

Discussion in 'ASP .Net Web Controls' started by bvly, Jul 21, 2003.

  1. bvly

    bvly Guest

    I'm not sure if this is what you are trying to do, but I
    was able to get an alert box from a datagrid by using a
    TemplateColumn and ItemTemplate with a button to call a
    function:
    <script language="JavaScript">
    function TestGridCall(src,args){
    alert("Hello" + event.srcElement.name);
    }

    </script>

    <asp:TemplateColumn>
    <ItemTemplate>
    <input type="button" name="xx" nclick="TestGridCall
    ()"/>
    </ItemTemplate>
    </asp:TemplateColumn>

    You'd have to explicitly create the columns.


    >-----Original Message-----
    >Can someone give me the server event/code to give a Web
    >Form DataGrid client-side JavaScript that would result in
    >the grid having a JavaScript onClick event handler for
    >each row of the grid?
    >
    >Thank you!
    >.
    >
    bvly, Jul 21, 2003
    #1
    1. Advertising

  2. bvly

    Scott M. Guest

    No, that's not quite what I'm looking for.

    I don't want to add any additional columns to the grid at all. I want to
    wind up with [<TR onClick="...javascript...">] in the DataGrid's resulting
    HTML sent to the client. Because the HTML for the grid is rendered at run
    time, you must add this code to one of the grid's events (render?) and what
    the actual code is to add the script to that HTML I don't know.


    "bvly" <> wrote in message
    news:019701c34fc0$7ea518d0$...
    > I'm not sure if this is what you are trying to do, but I
    > was able to get an alert box from a datagrid by using a
    > TemplateColumn and ItemTemplate with a button to call a
    > function:
    > <script language="JavaScript">
    > function TestGridCall(src,args){
    > alert("Hello" + event.srcElement.name);
    > }
    >
    > </script>
    >
    > <asp:TemplateColumn>
    > <ItemTemplate>
    > <input type="button" name="xx" nclick="TestGridCall
    > ()"/>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    >
    > You'd have to explicitly create the columns.
    >
    >
    > >-----Original Message-----
    > >Can someone give me the server event/code to give a Web
    > >Form DataGrid client-side JavaScript that would result in
    > >the grid having a JavaScript onClick event handler for
    > >each row of the grid?
    > >
    > >Thank you!
    > >.
    > >
    Scott M., Jul 21, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page