Adding Split Button Buttons Server Side Fails to Fire Click

8 posts, 1 answers
  1. John
    John avatar
    88 posts
    Member since:
    Nov 2007

    Posted 24 May 2011 Link to this post

    If I add a bunch of RibbonBarButtons to a RibbonBarSplitButton server side.  The OnSplitButtonClick event never fires when they are clicked.  How do I register that event to the server side created buttons?  And is there a way to have the control do that automatically in the future?
  2. Gimmik
    Gimmik avatar
    170 posts
    Member since:
    May 2011

    Posted 24 May 2011 Link to this post

    Hi John,

    You'll have to wire-up the server-side event before you'll be able to fire it from the RadRibbonBar. This is true of any ASP.NET control. If every client-side and server-side event were automatically wired-up for every control, you would manually have have code functions and methods to handle each event for every control used. That would quickly be hundreds of methods. I don't know about you, but I wouldn't want to read through that code! :)

    Here's a great link that will show you how to wire-up the event in question.
    http://www.telerik.com/help/aspnet-ajax/ribbonbar-server-splitbuttonclick.html

    Hope this helps,
    -Gimmik
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. John
    John avatar
    88 posts
    Member since:
    Nov 2007

    Posted 24 May 2011 Link to this post

    Maybe I wasn't clear, I'll try code to see if it works:

    On the aspx page
    <telerik:RadRibbonBar ID="RadRibbonBar1" runat="server" onSplitButtonClick="RadRibbonBar1_SplitButtonClick">
    <telerik:RibbonBarGroup Text="TEST">
    <Items>
    <telerik:RibbonBarSplitButton Size="Large" Text="TESTSTUFF" ImageURLLarge="SOMEIMAGE" ID="RBSB_TEST" runat="server">
    <Buttons></Buttons>
    </telerik:RibbonBarSplitButton>
    </Items>
    </telerik:RibbonBarGroup>
    </telerik:RadRibbonBar">

    In the code behind
    //In the page_init method
    List<object> items = dataSource.GetList();
    foreach(object item in items)
    {
    RibbonBarButton b = new RibbonBarButton();
    b.Text = item.Title;
    b.ImageURL = "someimage";
    RBSB_TEST.Buttons.Add(b);
    }
     
    protected void RadButtonBar1_SplitButtonClick(object sender, RibbonBarSplitButtonClickEventArgs e)
    {
          //Any button thats added server side never fires this event, if I add a button at design time, the click event fires
    }

    Somehow I need to register when adding the buttons server side, to fire this event, but I'm not sure how.
  5. Gimmik
    Gimmik avatar
    170 posts
    Member since:
    May 2011

    Posted 25 May 2011 Link to this post

    Hi John,

    I don't know what to tell you. I loaded your code and fixed a few typos. The server-side event is firing for me. Here's the runnable code that I used.

    My C# Code-Behind:
    protected void Page_Init(object sender, EventArgs e)
    {
        //In the page_init method
     
         
            RibbonBarButton b = new RibbonBarButton();
            b.Text = "Test SS";
            b.ImageUrl = Server.MapPath("~\\Jellyfish.jpg");
            RBSB_TEST.Buttons.Add(b);
         
    }
     
    protected void RadRibbonBar1_SplitButtonClick(object sender, RibbonBarSplitButtonClickEventArgs e)
    {
        Label1.Text = "Event Fired";
    }

    My ASPX file:
    <telerik:RadRibbonBar ID="RadRibbonBar1" runat="server" OnSplitButtonClick="RadRibbonBar1_SplitButtonClick">
        <telerik:RibbonBarTab>
            <telerik:RibbonBarGroup Text="TEST">
                <Items>
                    <telerik:RibbonBarSplitButton Size="Large" Text="TESTSTUFF" ImageUrlLarge="~/Jellyfish.jpg"
                        ID="RBSB_TEST" runat="server">
                    </telerik:RibbonBarSplitButton>
                </Items>
            </telerik:RibbonBarGroup>
        </telerik:RibbonBarTab>
    </telerik:RadRibbonBar>
    <asp:Label ID="Label1" runat="server" Text="Starter Text"></asp:Label>

    I hope some of this might help you.
    -Gimmik
  6. John
    John avatar
    88 posts
    Member since:
    Nov 2007

    Posted 26 May 2011 Link to this post

    I can't get this to work, just noticed I"m getting a javascript error on split button clicks.  Getting "Index was out of range.  Must be non-negative and less than the size of the collection." Parameter name: index

  7. John
    John avatar
    88 posts
    Member since:
    Nov 2007

    Posted 26 May 2011 Link to this post

    Here is my aspx code

    <%@ Master Language="C#" AutoEventWireup="true" CodeFile="kDNAMaster.master.cs" Inherits="net_kDNAMaster" %>
    <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <head runat="server">
        <title></title>
        <!--
            The Fugue Icons used are from http://www.pinvoke.com
            Copyright (C) 2009 Yusuke Kamiyamane. All rights reserved.
            The icons are licensed under a Creative Commons Attribution
            3.0 license. <http://creativecommons.org/licenses/by/3.0/>
         -->
        <link rel="shortcut icon" href="/images/kicon.ico" type="image/x-icon"/>
        <link href="~/styles/theme1/styles.css" rel="stylesheet" type="text/css" />
        <link href="~/styles/Editor.css" rel="stylesheet" type="text/css" />
        <link href="~/styles/DotNet.css" rel="stylesheet" type="text/css" />
        <script src='/search/searchhi.js?v=3.080' type='text/javascript'></script>
        <script src='/search/asearch.js?v=3.080' language="javascript" type="text/javascript"></script>
        <script src='/scripts/draganddrop.js?v=3.080' type='text/javascript'></script>
        <script src='/folders/kdna.js?v=3.080' language="javascript"  type="text/javascript"></script>
        <script src='/folders/InlineEditRow.js?v=3.080' language="javascript"  type="text/javascript"></script>
        <script src="/scripts/common.js?v=3.080" language="javascript" type="text/javascript"></script>
        <script src="/scripts/dateGetter.js?v=3.080" language="javascript" type="text/javascript"></script>
        <script src="/scripts/dotnetscripts.js?v=3.080" language="javascript" type="text/javascript"></script>
        <script src="/folders/additems.js?v=3.080" language="javascript" type="text/javascript"></script
        <asp:ContentPlaceHolder id="head" runat="server">
        </asp:ContentPlaceHolder>
        <telerik:RadCodeBlock ID="rcb1" runat="server">
            <script type="text/javascript">
                function launcherClicked() {
                    alert("Open Window to do preferences like password, email settings");
                }
            </script>
        </telerik:RadCodeBlock>
    </head>
    <body style="font-family: Arial; font-size: 10px; margin: 0; padding: 0;">
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>  
        <telerik:RadAjaxManager ID="RadAjaxMasterManager1" runat="server" OnAjaxRequest="RadAjaxMasterManager1_AjaxRequest" RequestQueueSize="5"  EnablePageHeadUpdate="false">
        </telerik:RadAjaxManager>
        <telerik:RadWindowManager ID="RadMasterWindows" runat="server" IconUrl="/images/blank.gif" Skin="Vista" Behaviors="Close,Maximize, Move" Width="640" Height="500" VisibleStatusbar="false">
        <Windows>
            <telerik:RadWindow Title="Help" ID="helpWindow" IconUrl="/images/blank.gif" runat="server" Width="800px" Height="600px" Modal="true" Behaviors="Close, Maximize, Move" NavigateUrl="/net/PopUpForms/searchHelp.aspx"></telerik:RadWindow>
            <telerik:RadWindow Title="About User Types" ID="UserTypesHelp" IconUrl="/images/blank.gif" runat="server" Width="800px" Height="600px" Modal="true" Behaviors="Close, Maximize, Move" NavigateUrl="/net/PopUpForms/UserTypesHelp.aspx"></telerik:RadWindow>
            <telerik:RadWindow Title="Video Training Reminder Email" ID="VideoTrainingReminderEmail" IconUrl="/images/blank.gif" runat="server" Width="640px" Height="480px" Modal="true" Behaviors="Close, Maximize, Move" NavigateUrl="/net/PopUpForms/VideoTrainingReminderEmail.aspx"></telerik:RadWindow>
            <telerik:RadWindow Title="Change Password" ID="WindowChangePassword" IconUrl="/images/blank.gif" runat="server" Width="530px" Height="350px" ReloadOnShow="true" ShowContentDuringLoad="false" Modal="true" Behaviors="Close" NavigateUrl="/net/PopUpForms/ChangePassword.aspx"></telerik:RadWindow>
            <telerik:RadWindow Title="Upload My Thumbnail" ID="AddPersonalThumbnail" IconUrl="/images/blank.gif" runat="server" Width="640px" Height="480px" ReloadOnShow="true" ShowContentDuringLoad="false" Modal="true" Behaviors="Close" NavigateUrl="/net/PopUpForms/AddPersonalThumbnail.aspx"></telerik:RadWindow>
            <telerik:RadWindow Title="Welcome Email Text" ID="SelectWelcomeEmailText" IconUrl="/images/blank.gif" runat="server" Width="605px" Height="380px" Modal="true" Behaviors="Close" NavigateUrl="/net/DialogWindows/SelectWelcomeEmailText.aspx" ShowContentDuringLoad="false" ReloadOnShow="true"></telerik:RadWindow>      
        </Windows>
        </telerik:RadWindowManager
        <div>
        <div style="background-color: #ffffff; padding-left: 5px;  font-size: 11px; font-weight: bold; margin-bottom: 1px;">
                <div style="float: left; margin-right: 135px; ">
                    <div style="float: left;padding-top: 2px;"><asp:Image ID="Image_Logo" runat="server" BorderStyle="None" ImageUrl="/images/logo.png"/></div>
                    <div style="float: left; padding: 4px 5px 4px 10px;">
                        <asp:Literal runat="server" ID="Literal_PoweredBy"></asp:Literal>
                    </div>                   
                    <div style="clear: both;"></div>
                </div>
                <div style="float: right;">
                    <div style="float: left; padding-top: 4px;">
                        <asp:Label ID="UsersName" runat="server" Font-Bold="false" ForeColor="#326599"></asp:Label>   
                    </div>
                    <div style="float: left; padding-top: 4px; padding-right: 10px; padding-left: 10px;">
                        <asp:Label ID="CurrentTimeStamp" runat="server" Font-Bold="false" ForeColor="#326599"></asp:Label>
                    </div>
                    <div style="float: left; padding: 4px 5px 4px 45px;">
                    <a href="/net/Home.aspx" style="text-decoration: none; color: #6699CC;">Home</a>
                    </div
                    <div style="float: left; padding-top: 4px; padding-left: 5px; padding-right: 5px; color: #264C72;">|</div>
                    <div style="float: left; padding: 4px 5px 4px 5px;">
                        <a href="/net/help.aspx" style="color: #6699CC; text-decoration: none;">Help</a>
                    </div>
                    <div style="float: left; padding-top: 4px; padding-left: 5px; padding-right: 5px; color: #264C72;">|</div>
                    <div style="float: left; padding: 4px 5px 4px 5px;">
                        <a href="/net/Training/Default.aspx" style="text-decoration: none; color: #6699CC;">Training</a>
                    </div>
                    <div style="float: left; padding-top: 4px; padding-left: 5px; padding-right: 5px; color: #264C72;">|</div>
                    <div style="float: left; padding: 4px 5px 4px 5px;">
                        <a href="/net/logout.aspx" style="color: #6699CC; text-decoration: none;">Logout</a>
                    </div>
                </div>
                <div style="clear: both;"></div>                                                          
            </div>
        </div>
        <div style="width: 100%; height: 130px; padding: 0px 0px;">
            <telerik:RadAjaxPanel ID="RadAjaxPanel_RadRibbonBar1" runat="server">
                <telerik:RadRibbonBar ID="RadRibbonBar1" runat="server" Width="100%" style="max-width: 100%;" Skin="Office2007" OnClientLauncherClicked="launcherClicked"
                OnButtonClick="RadRibbonBar1_ButtonClick"
                OnSplitButtonClick="RadRibbonBar1_SplitButtonClick"
            >
                <telerik:RibbonBarTab Text="To Dos">
                    <telerik:RibbonBarGroup Text="View Templates">
                        <Items>
                            <telerik:RibbonBarButton ID="RBB_Templates_Scoreboard" Size="Large" Text="Scoreboard" ImageUrlLarge="/images/Ribbon/scoreboard32.png"  />
                            <telerik:RibbonBarButton ID="RBB_Templates_Update" Size="Large" Text="Update" ImageUrlLarge="/images/Ribbon/updatetemplate32.png" />
                        </Items>
                    </telerik:RibbonBarGroup>
                     <telerik:RibbonBarGroup Text="Manage Templates">
                        <Items>
                             
                            <telerik:RibbonBarButton ID="RBB_Templates_Manage" Size="Large" Text="Manage" ImageUrlLarge="/images/Ribbon/managetemplates32.png" />
                            <telerik:RibbonBarSplitButton Size="Large" Text="Active" ImageUrlLarge="/images/Ribbon/template32.png" ID="RBSB_Templates" runat="server">
                                <Buttons>
     
                                </Buttons>
                            </telerik:RibbonBarSplitButton>
                            <telerik:RibbonBarSplitButton Size="Large" Text="Master" ImageUrlLarge="/images/Ribbon/template32.png" ID="RibbonBarSplitButton1" runat="server">
                                <Buttons>
     
                                </Buttons>
                            </telerik:RibbonBarSplitButton>
                            <telerik:RibbonBarButton ID="RBB_Templates_New" Size="Large" Text="New" ImageUrlLarge="/images/Ribbon/newtemplate32.png" />
                        </Items>
                    </telerik:RibbonBarGroup>
                    <telerik:RibbonBarGroup Text="Single To Dos">
                        <Items>
                            <telerik:RibbonBarButton ID="RBB_ToDos_ViewList" Size="Large" Text="View List" ImageUrlLarge="/images/Ribbon/viewtodolist32.png" />
                            <telerik:RibbonBarButton ID="RBB_ToDos_StartToDo" Size="Large" Text="New" ImageUrlLarge="/images/Ribbon/newtodo32.png" />
                            <telerik:RibbonBarButton ID="RBB_ToDos_AddMultiple" Size="Large" Text="Add Multiple" ImageUrlLarge="/images/Ribbon/multiple32.png" />
                             <telerik:RibbonBarSplitButton Size="Large" Text="To Dos" ImageUrlLarge="/images/Ribbon/todo32.png" ID="RBSB_ToDos" runat="server">
                                <Buttons>
                                     
                                </Buttons>
                            </telerik:RibbonBarSplitButton>
                        </Items>
                    </telerik:RibbonBarGroup>              
                </telerik:RibbonBarTab>
                <telerik:RibbonBarTab Text="Discussions">
                 <telerik:RibbonBarGroup Text="Discussions">
                     <Items>
                            <telerik:RibbonBarButton ID="RBB_Dissucssions_New" Size="Large" Text="New" ImageUrlLarge="/images/Ribbon/newdiscussion32.png" />
                            <telerik:RibbonBarSplitButton Size="Large" Text="View" ImageUrlLarge="/images/Ribbon/discussion32.png" ID="RBB_Discussions" runat="server">
                                <Buttons>
     
                                </Buttons>
                            </telerik:RibbonBarSplitButton>
                        </Items>
                    </telerik:RibbonBarGroup>
                </telerik:RibbonBarTab>
                <telerik:RibbonBarTab Text="Projects">
                    <telerik:RibbonBarGroup Text="Discussions">
                     <Items>
                            <telerik:RibbonBarButton ID="RBB_Projects_New" Size="Large" Text="New" ImageUrlLarge="/images/Ribbon/newproject32.png" />
                            <telerik:RibbonBarSplitButton Size="Large" Text="View" ImageUrlLarge="/images/Ribbon/project32.png" ID="RBB_Projects" runat="server">
                                <Buttons>
     
                                </Buttons>
                            </telerik:RibbonBarSplitButton>
                        </Items>
                    </telerik:RibbonBarGroup>
                </telerik:RibbonBarTab>
                <telerik:RibbonBarTab Text="Users & Groups">
                    <telerik:RibbonBarGroup Text="Users">
                        <Items>
                            <telerik:RibbonBarButton Size="Large" Text="Add" ImageUrlLarge="/images/Ribbon/addusers32.png" ID="RBB_Users_Add"/>
                            <telerik:RibbonBarButton Size="Large" Text="Edit" ImageUrlLarge="/images/Ribbon/editusers32.png" ID="RBB_Users_Edit" />
                            <telerik:RibbonBarButton Size="Large" Text="Groups" ImageUrlLarge="/images/Ribbon/group32.png" ID="RBB_Users_Groups" />
                            <telerik:RibbonBarButton Size="Large" Text="Welcome" ImageUrlLarge="/images/Ribbon/welcomeemail32.png" ID="RBB_Users_WelcomeEmail" />
                        </Items>
                    </telerik:RibbonBarGroup>
                    <telerik:RibbonBarGroup Text="Networks">
                        <Items>
                            <telerik:RibbonBarButton Size="Large" Text="Manage" ImageUrlLarge="/images/Ribbon/networkmanager32.png" ID="RBB_Networks_Manage" />
                        </Items>
                    </telerik:RibbonBarGroup>
                    <telerik:RibbonBarGroup Text="Import Users">
                        <Items>
                            <telerik:RibbonBarButton Size="Large" Text="Bulk Load" ImageUrlLarge="/images/Ribbon/bulkload.png" ID="RBB_Users_BulkLoad" />
                            <telerik:RibbonBarButton Size="Large" Text="Processing" ImageUrlLarge="/images/Ribbon/processing.png" ID="RBB_Users_Processing" />
                        </Items>
                    </telerik:RibbonBarGroup>
                </telerik:RibbonBarTab>
                <telerik:RibbonBarTab Text="View">
                    <telerik:RibbonBarGroup Text="Locations">
                        <Items>
                            <telerik:RibbonBarButton Size="Large" Text="Overview" ImageUrlLarge="/images/Ribbon/overview32.png" />
                            <telerik:RibbonBarSplitButton Size="Large" Text="Contents" ImageUrlLarge="/images/Ribbon/content32.png">
                                <Buttons>
                                </Buttons>
                            </telerik:RibbonBarSplitButton>
                            <telerik:RibbonBarSplitButton Size="Large" Text="Networks" ImageUrlLarge="/images/Ribbon/blocks32.png">
                                <Buttons>
                                </Buttons>
                            </telerik:RibbonBarSplitButton>
                        </Items>
                    </telerik:RibbonBarGroup>
                    <telerik:RibbonBarGroup Text="Personal">
                        <Items>
                        <telerik:RibbonBarSplitButton Size="Large" Text="Alerts" ImageUrlLarge="/images/Ribbon/alert32.png">
                                <Buttons>
                                </Buttons>
                            </telerik:RibbonBarSplitButton>
                            <telerik:RibbonBarSplitButton Size="Large" Text="Favorites" ImageUrlLarge="/images/Ribbon/fav32.png">
                                <Buttons>
                                </Buttons>
                            </telerik:RibbonBarSplitButton>
                            <telerik:RibbonBarSplitButton Size="Large" Text="History" ImageUrlLarge="/images/Ribbon/history32.png">
                                <Buttons>
                                </Buttons>
                            </telerik:RibbonBarSplitButton>
                        </Items>
                    </telerik:RibbonBarGroup>
                </telerik:RibbonBarTab>
                <telerik:RibbonBarTab Text="My Preferences">
                    <telerik:RibbonBarGroup Text="Preferences">
                        <Items>
                            <telerik:RibbonBarButton Size="Large" Text="Settings" ImageUrlLarge="/images/Ribbon/settings32.png" />
                            <telerik:RibbonBarButton Size="Large" Text="Profile" ImageUrlLarge="/images/Ribbon/profile32.png" />
                            <telerik:RibbonBarButton Size="Large" Text="Photo" ImageUrlLarge="/images/Ribbon/profile32.png" />
                            <telerik:RibbonBarButton Size="Large" Text="Password" ImageUrlLarge="/images/Ribbon/password32.png" />
                        </Items>
                    </telerik:RibbonBarGroup>
                </telerik:RibbonBarTab>
                <telerik:RibbonBarTab Text="Resources">
                    <telerik:RibbonBarGroup Text="Orientation">
                        <Items>
                            <telerik:RibbonBarButton Size="Large" Text="Welcome" ImageUrlLarge="/images/Ribbon/welcome32.png" />
                            <telerik:RibbonBarButton Size="Large" Text="Training" ImageUrlLarge="/images/Ribbon/training32.png" />
                            <telerik:RibbonBarButton Size="Large" Text="FAQ" ImageUrlLarge="/images/Ribbon/faq32.png" />
                            <telerik:RibbonBarButton Size="Large" Text="Help" ImageUrlLarge="/images/Ribbon/help32.png" />
                        </Items>
                    </telerik:RibbonBarGroup>
                </telerik:RibbonBarTab>
            </telerik:RadRibbonBar>
            </telerik:RadAjaxPanel>
        </div>
        <div>
            <asp:ContentPlaceHolder id="PageCode" runat="server">
     
            </asp:ContentPlaceHolder>
        </div>
        </form>
    </body>
    </html>


    Here is my cs code

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Xml.Linq;
    using System.Text;
    using Telerik.Web.UI;
    using kDNA.Core;
    using kDNA.Web;
    using kDNA.DB.Contents;
    using kDNA.Core.ToDos;
     
    public partial class net_kDNAMaster : System.Web.UI.MasterPage
    {
        private User thisUser;
        private Site thisSite;
        private Network thisPrimaryNetwork;
        private ItemRepository db = new ItemRepository();
        protected void Page_Load(object sender, EventArgs e)
        {
             
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                LoadUser();
                LoadActiveTemplates();
                LoadSingleToDos();
                LoadDiscussions();
                LoadProjects();
            }
        }
        public void RaisePostBackEvent(string eventArgument)
        {
     
        }
        public void LoadActiveTemplates()
        {
            RBSB_Templates.Buttons.Clear();
            List<ToDoRecurringSchedule> tdrs = ToDoRecurringSchedule.GetMyToDoRecurringSchedules(thisUser);
            foreach (ToDoRecurringSchedule tdr in tdrs.OrderBy(uu => uu.Title))
            {
                RibbonBarButton b = new RibbonBarButton();
                b.Text = tdr.Title;
                b.ImageUrl = "/Images/Ribbon/template16.png";
                b.Value = tdr.ToDoRecurringScheduleID.ToString();
                RBSB_Templates.Buttons.Add(b);
            }
        }
        public void LoadSingleToDos()
        {
            RBSB_ToDos.Buttons.Clear();
            ToDoList todos = ToDoList.GetSingleToDos(thisUser);
            foreach (ToDo td in todos.OrderBy(uu => uu.Title))
            {
                RibbonBarButton b = new RibbonBarButton();
                b.Text = td.Title;
                b.ImageUrl = "/Images/Ribbon/todo16.png";
                b.Value = td.ToDoID.ToString();
                RBSB_ToDos.Buttons.Add(b);
            }
        }
        public void LoadDiscussions()
        {
            RBB_Discussions.Buttons.Clear();
            List<kDNA.DB.db_Item> items = db.GetUserDiscussions(thisUser.UserID);
            foreach (kDNA.DB.db_Item item in items.OrderBy(uu => uu.Title))
            {
                RibbonBarButton b = new RibbonBarButton();
                b.Text = item.Title;
                b.ImageUrl = "/Images/Ribbon/discussion16.png";
                b.Value = item.ItemID.ToString();
                RBB_Discussions.Buttons.Add(b);
            }
        }
        public void LoadProjects()
        {
            RBB_Projects.Buttons.Clear();
            List<kDNA.DB.db_Item> items = db.GetUserProjects(thisUser.UserID);
            foreach (kDNA.DB.db_Item item in items.OrderBy(uu => uu.Title))
            {
                RibbonBarButton b = new RibbonBarButton();
                b.Text = item.Title;
                b.ImageUrl = "/Images/Ribbon/project16.png";
                b.Attributes.Add("ItemID", item.ItemID.ToString());
                b.Attributes.Add("ItemType", "Item");
                RBB_Projects.Buttons.Add(b);
            }
        }
        protected void RadAjaxMasterManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
        {
            if (e.Argument == "RefreshGrid")
            {
                (PageCode.FindControl("RadGrid1") as Telerik.Web.UI.RadGrid).Rebind();
            }
            else if (e.Argument == "RebindUserTrainingGrid")
            {
                (PageCode.FindControl("RadGrid1") as Telerik.Web.UI.RadGrid).Rebind();
            }
            else if (e.Argument == "RebindMyHistory")
            {
                //SetUpMyHistory();
            }
            else if (e.Argument == "RebindSavedSearches")
            {
                //SetUpSavedSearches();
            }
            else if (e.Argument == "ResetHomeTab")
            {
                thisUser = new User(SessionHandler.UserID);
                SessionHandler.User = thisUser;
                LoadHomeLink();
            }
            else if (e.Argument == "UpdateTimeStamp")
            {
                thisUser = new User(SessionHandler.UserID);
                //CurrentTimeStamp.Text = thisUser.MyTimeZone.GetTimeStamp(thisUser.Use24Clock);
            }
        }
        public User user()
        {
            if (thisUser == null)
            {
                LoadUser();
                return thisUser;
            }
            else
            {
                return thisUser;
            }
        }
        public Site site()
        {
            string cacheKey = "Site";
            Site cacheItem = Cache[cacheKey] as Site;
            if (cacheItem == null)
            {
                cacheItem = new Site();
                Cache.Insert(cacheKey, cacheItem, null, DateTime.UtcNow.AddHours(1), TimeSpan.Zero);
            }
            thisSite = cacheItem;
            return cacheItem;
        }
        public void LoadHomeLink()
        {
            int ct = thisUser.ItemsToModerate();
            if (ct > 0)
            {
                //RadMenu2.Items[0].Text = "<div style='color: Red; margin-left: 5px; float: left; width: 50px; padding-left: 10px;'>Home (" + ct.ToString() + ")</div><div style='clear: both;'></div>";
            }
            else
            {
               // RadMenu2.Items[0].Text = "<div style='margin-left: 5px; float: left; width: 50px; padding-left: 10px;'>Home</div><div style='clear: both;'></div>";
            }
     
        }
        private void LoadUser()
        {
            if (SessionHandler.UserID == 0)
            {
                SessionHandler.TransferSession(Request, HttpContext.Current.Session);
                if (SessionHandler.UserID == 0)
                {
                    Response.Redirect("/net/sessionlogin.asp?redirectpage=" + Request.ServerVariables["URL"] + "&" + Request.QueryString.ToString(), true);
                }
                else
                {
                    thisUser = new User(SessionHandler.UserID);
                    SessionHandler.User = thisUser;
                    SessionHandler.PrimaryNetwork = new Network(thisUser.PrimaryNetworkID);
                }
            }
            else
            {
                if (SessionHandler.User != null)
                {
                    thisUser = SessionHandler.User;
                    if (SessionHandler.PrimaryNetwork != null)
                    {
                        thisPrimaryNetwork = SessionHandler.PrimaryNetwork;
                    }
                    else
                    {
                        thisPrimaryNetwork = new Network(thisUser.PrimaryNetworkID);
                    }
                }
                else
                {
                    thisUser = new User(SessionHandler.UserID);
                    thisPrimaryNetwork = new Network(thisUser.PrimaryNetworkID);
                    SessionHandler.User = thisUser;
                    SessionHandler.PrimaryNetwork = thisPrimaryNetwork;
                }
            }
     
            if (Request.QueryString["fromemail"] == "yes")
            {
                string h = thisUser.SetHash();
                HttpCookie cookieID = new HttpCookie("ID");
                cookieID.Value = h;
                if (Request.Cookies["StayLoggedIn"].Value == "1")
                {
                    cookieID.Expires = System.DateTime.Now.AddYears(1);
                }
                Response.Cookies.Add(cookieID);
            }
            if (thisUser.UserStatusType != UserStatusType.Active)
            {
                Response.Redirect("/net/logout.aspx", true);
            }
        }
        public void SetSearchPhrase(string val)
        {
            //searchPhrase.Text = val;
        }
     
        protected void RadRibbonBar1_ButtonClick(object sender, RibbonBarButtonClickEventArgs e)
        {
            //IEnumerator keys = e.Button.Attributes.Keys.GetEnumerator();
            switch (e.Button.ID)
            {
                case "RBB_Templates_Scoreboard":
                    Response.Redirect("/Net/ToDos/Scoreboard.aspx", true);
                    break;
                case "RBB_Templates_Update":
                    Response.Redirect("/Net/ToDos/ScoreboardRankings.aspx", true);
                    break;
                case "RBB_Templates_Manage":
                    Response.Redirect("/Net/ToDos/ViewToDoTemplates.aspx", true);
                    break;
                case "RBB_Templates_New":
                    Response.Redirect("/Net/ToDos/CreateToDoTemplate.aspx", true);
                    break;
                case "RBB_ToDos_ViewList":
                    Response.Redirect("/Net/MyToDos.aspx", true);
                    break;
                case "RBB_ToDos_StartToDo":
                    Response.Redirect("/Net/Forms/ToDosForm.aspx?addnew=yes", true);
                    break;
                case "RBB_ToDos_AddMultiple":
                    Response.Redirect("/Net/ToDos/QuickAddToDos.aspx", true);
                    break;
                case "RBB_Users_Add":
                    Response.Redirect("/Net/Admin/Groups/AddNewUsers.aspx", true);
                    break;
                case "RBB_Users_WelcomeEmail":
                    Response.Redirect("/Net/Admin/WelcomeText.aspx", true);
                    break;
                case "RBB_Users_Groups":
                    Response.Redirect("/Net/Admin/Groups/GroupManager.aspx", true);
                    break;
                case "RBB_Users_Edit":
                    Response.Redirect("/Net/Admin/UserControls.aspx", true);
                    break;
                case "RBB_Networks_Manage":
                    Response.Redirect("/net/Admin/NetworksManager.aspx", true);
                    break;
                case "RBB_Users_BulkLoad":
                    Response.Redirect("/net/Admin/Groups/BulkLoadGroups.aspx", true);
                    break;
                case "RBB_Users_Processing":
                    Response.Redirect("/net/Admin/Groups/BulkLoadProcessing.aspx", true);
                    break;
            }
        }
        protected void RadRibbonBar1_SplitButtonClick(object sender, RibbonBarSplitButtonClickEventArgs e)
        {
            //IEnumerator keys = e.Button.Attributes.Keys.GetEnumerator();
            switch (e.Button.ID)
            {
                case "RBSB_ToDos":
                    string id = e.Button.Value;
                    Response.Redirect("/Net/todos.aspx?todid=" + id, true);
                    break;
                case "RBB_Discussions":
                    break;
                case "RBB_Projects":
                    break;
            }
        }
     
        public void ShowActiveTab(MasterTabs tab)
        {
            switch (tab)
            {
                case MasterTabs.ToDos:
                    RadRibbonBar1.SelectedTabIndex = 0;
                    break;
                case MasterTabs.Discussions:
                    RadRibbonBar1.SelectedTabIndex = 1;
                    break;
                case MasterTabs.Projects:
                    RadRibbonBar1.SelectedTabIndex = 2;
                    break;
                case MasterTabs.Users:
                    RadRibbonBar1.SelectedTabIndex = 3;
                    break;
                case MasterTabs.View:
                    RadRibbonBar1.SelectedTabIndex = 4;
                    break;
                case MasterTabs.Preferences:
                    RadRibbonBar1.SelectedTabIndex = 5;
                    break;
                case MasterTabs.Resources:
                    RadRibbonBar1.SelectedTabIndex = 6;
                    break;
            }
     
        }
     
        public enum MasterTabs
        {
            ToDos,
            Discussions,
            Projects,
            Users,
            View,
            Preferences,
            Resources
        }
    }
  8. Answer
    Simon
    Admin
    Simon avatar
    2281 posts

    Posted 31 May 2011 Link to this post

    Hello John,

    Your code is a bit different from the one you and Gimmik have tested previously - you create the RibbonBar controls only on the first page load. This is the reason for the server-side exception that appears when a split button is clicked.

    The problem is that individual RibbonBar items are not stored in ViewState, so they have to be recreated on each postback.
    if (!Page.IsPostBack)
    {
        LoadUser();
        LoadActiveTemplates();
        LoadSingleToDos();
        LoadDiscussions();
        LoadProjects();
    }

    We are currently planning to fix this so that items are stored in and recreated from ViewState so that such problems as yours do not exist.

    I hope this helps.

    Best wishes,
    Simon
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  9. John
    John avatar
    88 posts
    Member since:
    Nov 2007

    Posted 01 Jun 2011 Link to this post

    Ok, got it working with recreation on every postback.  Thanks.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017