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

Trouble with multiple panels

1 Answer 51 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Web Services
Top achievements
Rank 2
Web Services asked on 03 Oct 2011, 10:31 PM
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">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="updateDate">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="headerOutput" />
                    <telerik:AjaxUpdatedControl ControlID="myOutput" />
                    <telerik:AjaxUpdatedControl ControlID="headRepeat" />
                    <telerik:AjaxUpdatedControl ControlID="userInfoOutput" />
                    <telerik:AjaxUpdatedControl ControlID="userBlockChart" />
                    <telerik:AjaxUpdatedControl ControlID="output" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
 
<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">
            <ItemTemplate>
                <div class="headerImageRepeat" id="headerDiv" runat="server">
                    <table cellpadding="0" cellspacing="0" style="height: 70px;">
                        <tr>
                            <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>
                            <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") %>' />
                                </td></tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </div>
            </ItemTemplate>
        </asp:Repeater>
        </telerik:RadAjaxPanel>

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>"
                headerOutput.Show()
 
            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>"
                headerOutput.Show()
 
            End If 'if isnumeric
 
        End If 'if e.commandname
    End Sub


1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 06 Oct 2011, 03:36 PM
Hello,

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
Tags
Ajax
Asked by
Web Services
Top achievements
Rank 2
Answers by
Iana Tsolova
Telerik team
Share this question
or