Page view counter

Accessing datagrid Element using Javascipt

Last post 01-07-2009 3:55 AM by mudassarkhan. 2 replies.

Sort Posts:

  • Accessing datagrid Element using Javascipt

    01-07-2009, 1:36 AM
    • Loading...
    • aspeucac
    • Joined on 02-11-2008, 9:01 AM
    • Posts 8
    • Points 1

    Hi guys,

    Good day!

    I want to use this script for my textbox inside the footer of a datagrid that whenever I pressed enter

    it will click the button save.

     

    function validateLettersEnter()

    {

    k=window.event.keyCode

    if (((k>=65) && (k<=90)) || ((k>=97) && (k<=122)))

    { }

    else if(k==13)

    {

    event.keyCode=0;

    document.getElementById('btnSave').click() -----> I have a problem in this part because the btnSave is inside the footer of my datagrid

    return false;

    } else

    window.event.keyCode=0


     Would anybody knows the solution to this help...Tnx in advance.

  • Re: Accessing datagrid Element using Javascipt

    01-07-2009, 3:24 AM
    Answer
    • Loading...
    • Bhaarat
    • Joined on 01-03-2007, 10:05 AM
    • India
    • Posts 346
    • Points 1,248

    hi...

    u can do one thing

    use HTML button instedof asp:button

    so u can access the HTML control from clientside code... 

    Hope This help

     

    Bhaarat


    Remember to click "Mark as Answer" on the post that helps U

    My Blog
  • Re: Accessing datagrid Element using Javascipt

    01-07-2009, 3:55 AM
    Answer
    • Loading...
    • mudassarkhan
    • Joined on 02-28-2008, 5:28 AM
    • Mumbai, India
    • Posts 9,417
    • Points 52,184
    • TrustedFriends-MVPs

    you can get this way

    function GetButton() {

    var grid = document.getElementById("<%=dgGrid.ClientID %>") ;

    var elem = grid.getElementsByTagName("input");for (var i=0;i<elem.length;i++)

    {

    if((elem[i].type == "button" || elem[i].type == "submit" ) && elem[i].id.indexOf("btnSave") != -1)

    alert(elem[i].id);

    }

    }

Page 1 of 1 (3 items)