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

add/remove or make invisible items in toolbar

4 Answers 175 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Al
Top achievements
Rank 1
Al asked on 25 Jul 2008, 10:48 PM
I have a situation that I don't know how to resolve. Based on a dropdownlist, I want to:
1. Make 1 of two items invisible
2. Rebuild the toolbar with only the items I want to see

My tool bar would have with a dropdownlist and a combobox or a dropdownlist with a text box, (depending on the selected value of the dropdownlist)

Now I've noticed that I can build a toolbar on the fly. But no mention on templated items

Making each item visible/invisible on the client side isn't an option, as the screen starts to look odd after a few times of making the two items invisible & invisible..

I wrote some C# code to handle making it visible on the server side, but failed:

protected void OnSelectedIndexChanged_ddUserSearchContext(object sender, EventArgs e)

{

RadComboBox MakerRadCombo = (RadComboBox)RadToolbar1.FindControl("MakerRadCombo");

DropDownList ddUserChoce = (DropDownList)RadToolbar1.FindControl("ddUserSearchContext");

TextBox tbSearchContractNo = (TextBox) RadToolbar1.FindControl("tbSearchContractNo");

if (ddUserChoce.SelectedValue == "Contract")

{

MakerRadCombo.Visible =

false;

tbSearchContractNo.Visible =

true;

}

else if (ddUserChoce.SelectedValue == "Maker")

{

MakerRadCombo.Visible =

true;

tbSearchContractNo.Visible =

false; ;

}

}

It fails because tbSearchContractNo  = null (it's invisible in the beginning)

Any insight would be helpful.

Thanks in advance,
Al Gorup

4 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 28 Jul 2008, 02:31 PM
Hello Al,

You need to access the button which has the template control first. Here is a small example:
<telerik:RadToolBar ID="RadToolBar1" runat="server">  
            <CollapseAnimation Duration="200" Type="OutQuint" /> 
            <Items> 
                <telerik:RadToolBarButton runat="server" Text="Button 0">  
                </telerik:RadToolBarButton> 
                <telerik:RadToolBarButton runat="server" Text="Button 1">  
                    <ItemTemplate> 
                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
                    </ItemTemplate> 
                </telerik:RadToolBarButton> 
                <telerik:RadToolBarButton runat="server" Text="Button 2">  
                </telerik:RadToolBarButton> 
            </Items> 
        </telerik:RadToolBar> 
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Hide/Show textbox" /> 
 

protected void Button1_Click(object sender, EventArgs e)  
    {  
        TextBox textbox1 = (TextBox)RadToolBar1.FindItemByText("Button 1").FindControl("TextBox1");  
        textbox1.Visible = !textbox1.Visible;  
    } 

Also, we have created a new help topic: Adding and Editing Templates at Designtime.

Let us know how it goes.

Regards,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Al
Top achievements
Rank 1
answered on 28 Jul 2008, 03:54 PM
What version of toolbar are you using? I'm at 1.6.5
I don't have a 
CollapseAnimation. Nor is it possible to put an <ItemTemplate> in my button template. I have to use <radtoolbartemplatebutton> and <buttontemplate> for such things. Am I out of synch? I thought I installed the latest Telerik product, prior to its Microsoft Ajax integration.

Al

0
AlbertGorup
Top achievements
Rank 1
answered on 29 Jul 2008, 03:53 AM

I may have a different version. Or a damaged installation, as I do not have a designer for toolbar. I have just the choice of choosing a skin.

Also, I adapted your code to fit what I do have. Instead of doing a RadToolBar1.FindItemByText().FindControl(), I was able to do a RadToolBar1.FindControl().FindControl(). I don't have a FindItemByText

(another reason why I think I have a different version. My installed version in 2008 Q1, non-Microsoft Ajax version)

Now I have a different problem. My first item in the toolbar is a dropdownlist. First choice: a combobox appears. Send choice: a textbox. As I don't want a complete reload when I change options, I now put it into an iframe. My problem is the combobox's pulldown. It's staying in the iframe. How do I force it to stay on top? 

0
Peter
Telerik team
answered on 29 Jul 2008, 08:52 AM

It looks like you are using the classic version of RadToolBar. I strongly recommend that you upgrade to the ASP.NET AJAX version as it has many advantages to the old RadToolbar and in addition it has all previously known bugs resolved.

If you want to avoid postback, you can simply use RadAjaxManager or RadAjaxPanel.


Greetings,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ToolBar
Asked by
Al
Top achievements
Rank 1
Answers by
Peter
Telerik team
Al
Top achievements
Rank 1
AlbertGorup
Top achievements
Rank 1
Share this question
or