add/remove or make invisible items in toolbar

5 posts, 0 answers
  1. Al
    Al avatar
    12 posts
    Member since:
    Dec 2006

    Posted 25 Jul 2008 Link to this post

    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

  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 28 Jul 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Al
    Al avatar
    12 posts
    Member since:
    Dec 2006

    Posted 28 Jul 2008 Link to this post

    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
    
    
  5. AlbertGorup
    AlbertGorup avatar
    8 posts
    Member since:
    Jul 2006

    Posted 28 Jul 2008 Link to this post

    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? 

  6. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 29 Jul 2008 Link to this post


    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017