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

Having ajax problems in courseware

1 Answer 54 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Dennis
Top achievements
Rank 1
Dennis asked on 27 Jan 2009, 09:26 PM
Pretty sure I've followed every step but I've got two issues with the section on updating a label from a calendar click:

1) The ajax panel isn't working, I'm getting a full-page postback. I checked to make sure the calendar and label are contained inside the panel.

2) AjaxManager updates the label nicely, no postback, but when I click an arrow to change the month, the month doesn't change. I do get a quick refresh of the label...oddly, with a shorter delay than the 200ms when I click a day.

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 30 Jan 2009, 02:18 PM
Hello Dennis,

Straight onto your questions:

1) Please verify if with regular postback the label is updated properly. To ajaxify some controls, you need to wrap them only inside RadAjaxPanel. Thus the RadAjaxPanel will handle whole postbacks initiated from controls in it.

Here is a code snippet how I attained an asynchronous update of the label:
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title></title>  
</head> 
<body> 
    <form id="form1" runat="server">  
    <asp:ScriptManager ID="ScriptManager1" runat="server">  
    </asp:ScriptManager> 
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">  
        <telerik:RadCalendar runat="server" Font-Names="Arial,Verdana,Tahoma" ForeColor="Black" 
            Style="border-color: #ececec" ID="RadCalendar1" AutoPostBack="true" ViewSelectorText="x" OnSelectionChanged="RadCalendar1_SelectionChanged">  
        </telerik:RadCalendar> 
        <div> 
            <h1> 
                Label:  
            </h1> 
            <asp:Label ID="lblDate" runat="server" Text="No date"></asp:Label> 
        </div> 
    </telerik:RadAjaxPanel> 
    </form> 
</body> 
</html> 

Here is the handler of the SelectedIndexChanged event:
    protected void RadCalendar1_SelectionChanged(object sender, Telerik.Web.UI.Calendar.SelectedDatesEventArgs e)  
    {  
        if (e.SelectedDates.Count > 0)  
        {  
            lblDate.Text = e.SelectedDates[0].Date.ToShortDateString();  
        }  
    } 
Please note that the collection SelectedDates contains the list of all selected dates.

2) If you are using RadAjaxManager, avoid using of RadAjaxPanel.

Below is a code excerpt which implements the approach with RadAjaxManager:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="RadCalendar1">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadCalendar1" /> 
                    <telerik:AjaxUpdatedControl ControlID="lblDate" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 

For further information you can refer to these links:
Ajax manager, Ajax panel

Regards,
Georgi Krustev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Ajax
Asked by
Dennis
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or