Trouble with multiple panels

2 posts, 0 answers
  1. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 03 Oct 2011 Link to this post

    I have multiple ajax panels on my page. I tried to configure it to update an asp label and to also show a tool tip on an image button click within a repeater. However, when I click the image, nothing on the front end get's updated. My code does run, I have verfied because the database get's updated. Can anyone tell me what I'm doing wrong?

        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <telerik:AjaxSetting AjaxControlID="updateDate">
                        <telerik:AjaxUpdatedControl ControlID="headerOutput" />
                        <telerik:AjaxUpdatedControl ControlID="myOutput" />
                        <telerik:AjaxUpdatedControl ControlID="headRepeat" />
                        <telerik:AjaxUpdatedControl ControlID="userInfoOutput" />
                        <telerik:AjaxUpdatedControl ControlID="userBlockChart" />
                        <telerik:AjaxUpdatedControl ControlID="output" />
    <telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
        <telerik:RadToolTip ID="headerOutput" Skin="Windows7" Position="Center" runat="server"
        CssClass="headerTooltip" Height="60" Width="220" AutoCloseDelay="4000"></telerik:RadToolTip>       
            <asp:Label ID="myOutput" runat="server"></asp:Label>
            <br />
            <asp:Repeater ID="headRepeat" runat="server">
                    <div class="headerImageRepeat" id="headerDiv" runat="server">
                        <table cellpadding="0" cellspacing="0" style="height: 70px;">
                                <td style="padding-left: 10px; padding-top: 5px; padding-right: 10px;" valign="top">
                                    <asp:ImageButton ID="headerImage" runat="server" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "headerImageUrl") %>'
                                     CommandName="showUsers" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ID") %>' />
                                <td style="padding-bottom: 5px; padding-top: 5px;" valign="bottom">               
                                    <asp:Label ID="memberName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "memberNameOutput") %>'></asp:Label><br />
                                    <span class="headerGoal"><asp:Label ID="memberHours" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "memberHoursOutput") %>'></asp:Label> hours per day</span><br />
                                    <table cellpadding="0" cellspacing="0" border="0"><tr><td valign="middle" class="headerGoal">
                                    Goal: <asp:textbox CssClass="goalTextbox" ID="goalInput" runat="server"
                                    Text='<%# DataBinder.Eval(Container.DataItem, "memberGoalOutput") %>' Width="40px"></asp:textbox
                                    </td><td valign="top" class="headerGoal"><asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="../images/save.png" CommandName="updateHours" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ID") %>' />

    And here is the code behind

    'they clicked the save button in header for goal hours
        Private Sub headRepeat_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles headRepeat.ItemCommand
            If (e.CommandName.ToString = "showUser") Then
                'this is not getting updated
                userInfoOutput.Text = "test"
            End If 'if e.commandNmae = showUser
            'if they clicked the save in the repeater
            If (e.CommandName.ToString = "updateHours") Then
                Dim memberId = e.CommandArgument.ToString
                Dim currentUser = Membership.GetUser.ProviderUserKey.ToString
                Dim hoursTextbox = TryCast(e.Item.FindControl("goalInput"), TextBox)
                Dim hoursInput = hoursTextbox.Text
                'check if we have a number otherwise we tell them we need a number
                If (IsNumeric(hoursInput)) Then
                    Dim sql = "SELECT * FROM MemberGoal WHERE memberId = '" & memberId & "' AND webUserId = '" & currentUser & "'"
                    'if this has a row then we update, otherwise we insert
                    If (awesome.checkRecord(sql, dashConn)) Then
                        sql = "UPDATE MemberGoal SET hourGoal = " & hoursInput & " WHERE memberId = '" & memberId & "' AND webUserId = '" & currentUser & "'"
                    Else 'we are inserting
                        sql = "INSERT INTO MemberGoal(hourGoal, memberId, webUserId) VALUES(" & hoursInput & ", '" & memberId & "', '" & currentUser & "')"
                    End If 'if
                    awesome.executeQuery(sql, dashConn)
                    'this is not getting updated
                    headerOutput.Text = "<center style='padding-top: 20px;'>The hours were updated for the user</center>"
                Else 'else we need to tell them we need a number
                    headerOutput.Text = "<center style='padding-top: 20px;' class='errorText'>Please enter a number.</center>"
                End If 'if isnumeric
            End If 'if e.commandname
        End Sub

  2. Iana Tsolova
    Iana Tsolova avatar
    3388 posts

    Posted 06 Oct 2011 Link to this post


    Firstly, it is suggested to use only one ajax control for ajaxifying particular page content. Thus as you already ajaxified the whole Repeater with RadAjaxPanel, you do nt need to add its controls in the ajax settings of the RadAjaxManager. Otherwise, you can get side effect of having nested ajax panels managed by different ajax controls and get unexpected results.
    Additionally, can you confirm the setup works properly without ajax?
    However I prepared a sample using your code which works properly on my side. Can you try and let me know if I missed something out?

    Best wishes,
    Iana Tsolova
    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
  3. DevCraft R3 2016 release webinar banner
Back to Top