DatePicker and XmlHttpPanel

2 posts, 0 answers
  1. Adriana
    Adriana avatar
    1 posts
    Member since:
    Jul 2010

    Posted 13 Apr 2013 Link to this post

    Hello,

    I am rather new to this, so if this is not the right place for this question, please let me know where and how I should proceed.
    I have a problem since the last upgrade (v2013.1.403.40).
    I have the following:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
    <%@ Register TagPrefix="telerik" Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" %>
    <!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>
        <script>
            function someCallback(panelId) {
                var panel = $find(panelId);
                if (panel) {
                    panel.set_value('');
                }
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <telerik:RadDatePicker ID="RadDatePicker1" runat="server" OnSelectedDateChanged="datechanged"
                AutoPostBack="true" EnableViewState="true" >
            </telerik:RadDatePicker>
            <telerik:RadXmlHttpPanel ID="rxhp" runat="server" Value="" OnServiceRequest="serviceRequest"
                RenderMode="Block" EnableClientScriptEvaluation="true" Width="100%">
                <br />
                <input runat="server" id="test_input" type="text" />
            </telerik:RadXmlHttpPanel>
        </div>
        </form>
    </body>
    </html>

    with this code:

    using System;
    using Telerik.Web.UI;
    using Telerik.Web.UI.Calendar;
     
    public partial class Default3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.test_input.Attributes.Add("onclick", string.Format("someCallback('{0}');", this.rxhp.ClientID));
            if (!IsPostBack)
            {
                RadDatePicker1.SelectedDate = DateTime.Now;
            }
        }
        protected void datechanged(object sender, SelectedDateChangedEventArgs e)
        {  
        }
        protected void serviceRequest(object sender, RadXmlHttpPanelEventArgs e)
        {  
        }
    }

    My problem is that whenever the service request is made (in this case onclick on the input) also the SelectedDateChanged event of the date picker is raised and the selected date is null.
    Can you possibly tell me what can cause this or how to fix this?
  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 17 Apr 2013 Link to this post

    Hi Adriana,

    The XmlHttpPanel does not sends the ViewState of your picker, and this is the reason it does not work correct. Use RadAjaxPanel(or asp:UpdatePanel) instead of the XmlHttpPanel.

    Kind regards,
    Vasil
    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. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top