Enabling Toolbar buttons from client-side script

C

Cathie

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
 
M

Mas Jabier

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
 
C

Cathie

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 said:
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


.
 
C

Cathie

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 said:
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 said:
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


.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top