Referencing a LinkButton in javascript

Discussion in 'ASP .Net' started by DanG, Oct 3, 2006.

  1. DanG

    DanG Guest

    Hi

    I used to have an ImageButton in my datagrid, and referenced the
    control in the javascript with:
    var fld = document.getElementById('datagrid__ctl2_btnEdit');
    alert(fld); //returns "[object]" >> Good

    I changed the ImageButton to a LinkButton, but the javascript doesn't
    work anymore.
    var fld = document.getElementById('datagrid__ctl2_btnEdit'); //Same as
    above
    alert(fld); //returns "javascript:
    __doPostBack('datagrid$_ctl2$btnEdit','');" >> Bad

    It's returning the javascript to execute, rather than the object
    itself.

    So how do I reference the LinkButton object???

    TIA
    Dan
     
    DanG, Oct 3, 2006
    #1
    1. Advertising

  2. You should not hard code .NET controls in JavaScript. You should assemble
    the JavaScript in the code behind and reference the name of the control
    there so you can switch controls without a lot of pain.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA
    http://gregorybeamer.spaces.live.com

    *************************************************
    Think outside of the box!
    *************************************************
    "DanG" <> wrote in message
    news:...
    > Hi
    >
    > I used to have an ImageButton in my datagrid, and referenced the
    > control in the javascript with:
    > var fld = document.getElementById('datagrid__ctl2_btnEdit');
    > alert(fld); //returns "[object]" >> Good
    >
    > I changed the ImageButton to a LinkButton, but the javascript doesn't
    > work anymore.
    > var fld = document.getElementById('datagrid__ctl2_btnEdit'); //Same as
    > above
    > alert(fld); //returns "javascript:
    > __doPostBack('datagrid$_ctl2$btnEdit','');" >> Bad
    >
    > It's returning the javascript to execute, rather than the object
    > itself.
    >
    > So how do I reference the LinkButton object???
    >
    > TIA
    > Dan
    >
     
    Cowboy \(Gregory A. Beamer\), Oct 3, 2006
    #2
    1. Advertising

  3. Check the value of fld.getType();

    -Keith

    "DanG" wrote:

    > Hi
    >
    > I used to have an ImageButton in my datagrid, and referenced the
    > control in the javascript with:
    > var fld = document.getElementById('datagrid__ctl2_btnEdit');
    > alert(fld); //returns "[object]" >> Good
    >
    > I changed the ImageButton to a LinkButton, but the javascript doesn't
    > work anymore.
    > var fld = document.getElementById('datagrid__ctl2_btnEdit'); //Same as
    > above
    > alert(fld); //returns "javascript:
    > __doPostBack('datagrid$_ctl2$btnEdit','');" >> Bad
    >
    > It's returning the javascript to execute, rather than the object
    > itself.
    >
    > So how do I reference the LinkButton object???
    >
    > TIA
    > Dan
    >
    >
     
    =?Utf-8?B?S2VpdGg=?=, Oct 3, 2006
    #3
  4. DanG

    DanG Guest

    I tried fld.getType(); "Object does not support this property or
    method".
     
    DanG, Oct 3, 2006
    #4
    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.
Similar Threads
  1. Fresh Air Rider
    Replies:
    0
    Views:
    545
    Fresh Air Rider
    Mar 2, 2004
  2. Jeelz
    Replies:
    2
    Views:
    616
    Vidar Petursson
    Jun 28, 2003
  3. Sathyaish
    Replies:
    3
    Views:
    3,111
    Sathyaish
    Sep 8, 2005
  4. Peter
    Replies:
    7
    Views:
    1,923
    Peter
    Jul 1, 2009
  5. Sathyaish

    Linkbutton does not look like a linkbutton

    Sathyaish, Sep 8, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    188
    Sathyaish
    Sep 8, 2005
Loading...

Share This Page