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

Loading images into PanelBar on page load

1 Answer 17 Views
This is a migrated thread and some comments may be shown as answers.
Justyn Hunter
Top achievements
Rank 1
Justyn Hunter asked on 18 May 2012, 09:36 PM
I have a page where I am using a RadPanelBar as a menu.

I want to kick off an ajax process when a page loads that does some database work and then changes an image on each item in the panelbar according to the results.

So far I have:

<telerik:RadCodeBlock runat="server">
    <script type="text/javascript">
        function pageLoad(sender, eventArgs) {
            if (!eventArgs.get_isPartialLoad()) {
                $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("InitialLoad");

Which successfully kicks off my process when the page loads, so I'm good there.

The problem is that the images in the PanelBar never change.

My RadAjaxManager looks like so:

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
            <telerik:AjaxSetting AjaxControlID="pbMenu">
                    <telerik:AjaxUpdatedControl ControlID="pbMenu" />

and the work code looks like:

protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e) {
            if (e.Argument == "InitialLoad") {
        private void RunLoadSim(RadPanelItemCollection items) {
            foreach (RadPanelItem i in items) {
                i.ImageUrl = "~/images/menublocks/grey.png";
                var start = new ParameterizedThreadStart(Sim);
                var thread = new Thread(start);
        private static void Sim(object arg) {
            var r = new Random();
            var i = r.Next(200, 5000);
            var green = r.Next(0, 2) == 0;
            var imgUrl = green ? "green" : "red";
            ((RadPanelItem) arg).ImageUrl = "~/Images/MenuBlocks/" + imgUrl + ".png";

The "work" code is just garbage to simulate db look ups right now.

Basically it sets the image in every panelbaritem to a grey square, then runs a fake worker process that sits for .2 to 5.0 seconds then loads either a green or red image in place of the grey one.

None of the colored squares ever appear though.

What am I doing wrong?


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 23 May 2012, 07:48 AM
Hi Justyn,

Try adding an AjaxSetting where RadAjaxManager1 updates pbMenu. It is requried when making an ajax request through the manager's client api.

All the best,
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Asked by
Justyn Hunter
Top achievements
Rank 1
Answers by
Telerik team
Share this question