Enabling Toolbar buttons from client-side script

Discussion in 'ASP .Net Web Controls' started by Cathie, Dec 19, 2003.

  1. Cathie

    Cathie Guest

    Hi All,

    I am having a problem enabling and disabling toolbar buttons from client
    side script. I have tried the following:

    var btnDelete = document.getElementsByName("btnDelete")[0];

    but this does not find the button at all.

    I can find the outside toolbar container:
    var tbrNewReport = document.getElementsByName("tbrNewReport")[0];

    but this doesn't seem to help me as I can't find a way to retrieve the
    buttons contained within the toolbar.

    I am enabling and disabling the buttons based on the number of items
    selected by a client. I really would prefer not to PostBack to do this as
    the extra round trips seem worthless.

    Can anyone help me?

    Thanks in advance,
    Cathie
    Cathie, Dec 19, 2003
    #1
    1. Advertising

  2. Cathie

    Mas Jabier Guest

    Cathie,

    If you use Javascript as client-side lang, it should be
    like this to disable specific button :

    function disable_buttons()
    ...
    frm.ctl0.disable = true
    where frm is your form name, and ctl0 is the 1st control
    (based on your code it may be vary). Just get View Source
    to see what your control naming in IE.

    Hope this helps :)

    Jody Ananda
    MCAD,MCSD.Net



    >-----Original Message-----
    >Hi All,
    >
    >I am having a problem enabling and disabling toolbar

    buttons from client
    >side script. I have tried the following:
    >
    >var btnDelete = document.getElementsByName("btnDelete")

    [0];
    >
    >but this does not find the button at all.
    >
    >I can find the outside toolbar container:
    >var tbrNewReport = document.getElementsByName

    ("tbrNewReport")[0];
    >
    >but this doesn't seem to help me as I can't find a way to

    retrieve the
    >buttons contained within the toolbar.
    >
    >I am enabling and disabling the buttons based on the

    number of items
    >selected by a client. I really would prefer not to

    PostBack to do this as
    >the extra round trips seem worthless.
    >
    >Can anyone help me?
    >
    >Thanks in advance,
    >Cathie
    >
    >
    >.
    >
    Mas Jabier, Dec 19, 2003
    #2
    1. Advertising

  3. Cathie

    Cathie Guest

    This doesn't work.

    As I said: I cannot actually get the button as it is a toolbar button on a
    Microsoft.Web.UI.WebControls.Toolbar therefore frm.btnDelete.disabled = true
    just causes an error as frm.btnDelete is undefined eventhough I am using the
    correct identifiers.

    I have advanced a little further and have been able to retrieve the toolbar
    button using:
    var btnDelete = tbrNewReport.getItem(2);

    This returns a "toolbar item" which I can't directly use btnDelete.disabled
    = true on. I have tried
    tbrNewReport.setAttribute(btnDelete, "disabled", "false");
    but this doesn't seem to work. What am I missing? I am sure this should be
    simple it is just not working for me.

    Thanks,
    Cathie

    "Mas Jabier" <> wrote in message
    news:07a201c3c5df$61ce6140$...
    > Cathie,
    >
    > If you use Javascript as client-side lang, it should be
    > like this to disable specific button :
    >
    > function disable_buttons()
    > ..
    > frm.ctl0.disable = true
    > where frm is your form name, and ctl0 is the 1st control
    > (based on your code it may be vary). Just get View Source
    > to see what your control naming in IE.
    >
    > Hope this helps :)
    >
    > Jody Ananda
    > MCAD,MCSD.Net
    >
    >
    >
    > >-----Original Message-----
    > >Hi All,
    > >
    > >I am having a problem enabling and disabling toolbar

    > buttons from client
    > >side script. I have tried the following:
    > >
    > >var btnDelete = document.getElementsByName("btnDelete")

    > [0];
    > >
    > >but this does not find the button at all.
    > >
    > >I can find the outside toolbar container:
    > >var tbrNewReport = document.getElementsByName

    > ("tbrNewReport")[0];
    > >
    > >but this doesn't seem to help me as I can't find a way to

    > retrieve the
    > >buttons contained within the toolbar.
    > >
    > >I am enabling and disabling the buttons based on the

    > number of items
    > >selected by a client. I really would prefer not to

    > PostBack to do this as
    > >the extra round trips seem worthless.
    > >
    > >Can anyone help me?
    > >
    > >Thanks in advance,
    > >Cathie
    > >
    > >
    > >.
    > >
    Cathie, Dec 19, 2003
    #3
  4. Cathie

    Cathie Guest

    Woohoo. Finally figured it out.

    I had to change the toolbar.htc setAtrribute method as well the call was
    slightly different:

    function EnableFunctions() {
    var btnDelete = tbrNewReport.getItem(2);
    var btnMove = tbrNewReport.getItem(3);
    if (selectedCount >= 1) {
    btnDelete.setAttribute("disabled", "false");
    btnMove.setAttribute("disabled", "false");
    } else {
    btnDelete.setAttribute("disabled", "true");
    btnMove.setAttribute("disabled", "true");
    }
    }

    HTC code:

    function f_PublicSetAttribute(item, name, value)
    {

    .....

    case "disabled":
    if (value.toLowerCase() == "true") {
    item.disabled = true;
    }else {
    item.disabled = false;
    }
    f_ApplyStylesToChildren();
    break;
    }


    "Cathie" <> wrote in message
    news:%...
    > This doesn't work.
    >
    > As I said: I cannot actually get the button as it is a toolbar button on a
    > Microsoft.Web.UI.WebControls.Toolbar therefore frm.btnDelete.disabled =

    true
    > just causes an error as frm.btnDelete is undefined eventhough I am using

    the
    > correct identifiers.
    >
    > I have advanced a little further and have been able to retrieve the

    toolbar
    > button using:
    > var btnDelete = tbrNewReport.getItem(2);
    >
    > This returns a "toolbar item" which I can't directly use

    btnDelete.disabled
    > = true on. I have tried
    > tbrNewReport.setAttribute(btnDelete, "disabled", "false");
    > but this doesn't seem to work. What am I missing? I am sure this should

    be
    > simple it is just not working for me.
    >
    > Thanks,
    > Cathie
    >
    > "Mas Jabier" <> wrote in message
    > news:07a201c3c5df$61ce6140$...
    > > Cathie,
    > >
    > > If you use Javascript as client-side lang, it should be
    > > like this to disable specific button :
    > >
    > > function disable_buttons()
    > > ..
    > > frm.ctl0.disable = true
    > > where frm is your form name, and ctl0 is the 1st control
    > > (based on your code it may be vary). Just get View Source
    > > to see what your control naming in IE.
    > >
    > > Hope this helps :)
    > >
    > > Jody Ananda
    > > MCAD,MCSD.Net
    > >
    > >
    > >
    > > >-----Original Message-----
    > > >Hi All,
    > > >
    > > >I am having a problem enabling and disabling toolbar

    > > buttons from client
    > > >side script. I have tried the following:
    > > >
    > > >var btnDelete = document.getElementsByName("btnDelete")

    > > [0];
    > > >
    > > >but this does not find the button at all.
    > > >
    > > >I can find the outside toolbar container:
    > > >var tbrNewReport = document.getElementsByName

    > > ("tbrNewReport")[0];
    > > >
    > > >but this doesn't seem to help me as I can't find a way to

    > > retrieve the
    > > >buttons contained within the toolbar.
    > > >
    > > >I am enabling and disabling the buttons based on the

    > > number of items
    > > >selected by a client. I really would prefer not to

    > > PostBack to do this as
    > > >the extra round trips seem worthless.
    > > >
    > > >Can anyone help me?
    > > >
    > > >Thanks in advance,
    > > >Cathie
    > > >
    > > >
    > > >.
    > > >

    >
    >
    Cathie, Dec 19, 2003
    #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. Magnus Blomberg
    Replies:
    3
    Views:
    718
    Magnus Blomberg
    Apr 14, 2005
  2. Boss302
    Replies:
    0
    Views:
    1,042
    Boss302
    Nov 21, 2006
  3. James Radke

    Problem enabling checkbox from client-side javascript - help!

    James Radke, Jan 22, 2004, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    456
    Jeffrey Tan[MSFT]
    Jan 27, 2004
  4. ~Maheshkumar.R

    Enabling/ Disabling Radio button in client side = Asp.net

    ~Maheshkumar.R, Mar 22, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    200
    ~Maheshkumar.R
    Mar 22, 2005
  5. pcouas
    Replies:
    0
    Views:
    259
    pcouas
    Feb 19, 2007
Loading...

Share This Page