This is a migrated thread and some comments may be shown as answers.

GetButtonByCommand shows alert box

1 Answer 51 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
caglar_ozkul
Top achievements
Rank 1
caglar_ozkul asked on 23 Jun 2008, 09:04 AM
Hi,

When i use GetButtonByCommand method of toolbar it shows an alert box that says: "Cannot find a button with such command name!"

I know there is no buttons with such name, but my buttons are being loaded dynamically.

So i should use
if (GetButtonByCommand("cmdSome"))
    toolbar.DisableButton(GetButtonByCommand("cmdSome"));

So the GetButtonByCommand should return null if it can not find that button. And not alert anything i hope.

Kind Regards,
Caglar Ozkul

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 23 Jun 2008, 02:28 PM
Hello caglar_ozkul,

GetButtonByCommand does not produce the alert - it is DisableButton. To avoid this first check if GetButtonByCommand returns -1 and then call DisableButton:

if (GetButtonByCommand("cmdSome") > -1)
    toolbar.DisableButton(GetButtonByCommand("cmdSome"));

You are right that the GetButtonByCommand should have returned null when the button isn't found. We have implemented it that way in RadToolbar for ASP.NET Ajax.

Regards,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ToolBar
Asked by
caglar_ozkul
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or