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

[Solved] DatePicker Script Error

7 Answers 286 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Rafael Avila
Top achievements
Rank 1
Rafael Avila asked on 28 Aug 2008, 02:15 PM
I'm trying to use the RadDatePicker, but just after drag and drop the component I got a javascript error message (on Firefox's Errors Console):

Erro: missing : after property id
Arquivo-fonte: http://localhost:2279/DevelopmentWebsite/Modulos/Default.aspx#
Linha: 8, Coluna: 252
Código-fonte:
' de \'MMMM","ddd, dd MMM yyyy HH\':\'mm\':\'ss \'GMT\'","d/M/yyyy","H:mm","yyyy\'-\'MM\'-\'dd\'T\'HH\':\'mm\':\'ss","yyyy\'-\'MM\'-\'dd HH\':\'mm\':\'ss\'Z\'","MMMM\' de \'yyyy",,,"/",":",0],"_ViewRepeatableDays":{},"_ViewsHash":{ctl00_DefaultContent_~/M

Sorry for some non-english texts on the error.

My scenario is a little complex:

An Ajaxified RadTabStrip (with RadAjaxManager) loads controls into dinamically created PageViews . The DatePicker is in a form inside one of these Controls. The form has a RadAjaxPanel.

Notes:
  • EnablePageHeadUpdate="false doesn't solve the problem as said at the thread (http://www.telerik.com/community/forums/thread/b311D-begbae.aspx)
  • I'm using RadControls  for ASPNET AJAX Q1 2008
Is there any alternative solution for this issue?

7 Answers, 1 is accepted

Sort by
0
Missing User
answered on 28 Aug 2008, 02:26 PM
Hello Rafael Avila,

Can you please open a support ticket and send us a simple runnable project that reproduces the issue you are experiencing? Once we have a better view over your scenario, we will do our best to provide a solution.

Best wishes,
Plamen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Scott Bedard
Top achievements
Rank 1
answered on 10 Mar 2009, 07:23 PM
Have you figured this out? I think I am having the same issue when a date picker is added dynamically inside a radpageview. I get a ':' expected error.
0
Louis Meijer
Top achievements
Rank 1
answered on 09 Apr 2009, 01:33 PM
I have the same error as Scott , if the RadDatePicker is inside a control that is loaded dynamically A javascript error apears:
missing : after property id
Sys$_ScriptLoader$_loadScriptsInternal()ScriptRe...=47910a7c (line 3621)
Sys$_ScriptLoader$_loadScriptsInternal()ScriptRe...=47910a7c (line 3626)
Sys$_ScriptLoader$_loadScriptsInternal()ScriptRe...=47910a7c (line 3626)
Sys$_ScriptLoader$_loadScriptsInternal()ScriptRe...=47910a7c (line 3626)
Sys$_ScriptLoader$_loadScriptsInternal()ScriptRe...=47910a7c (line 3626)
Sys$_ScriptLoader$_loadScriptsInternal()ScriptRe...=47910a7c (line 3626)
Sys$_ScriptLoader$_loadScriptsInternal()ScriptRe...=47910a7c (line 3626)
Sys$_ScriptLoader$_nextSession()ScriptRe...=47910a7c (line 3648)
Sys$_ScriptLoader$_loadScriptsInternal()ScriptRe...=47910a7c (line 3635)
(?)()()ScriptRe...=47910a7c (line 47)
(?)()()ScriptRe...=47910a7c (line 3852)
"HH:mm","yyyy\'-\'MM\'-\'dd\'T\'HH\':\'m...Reports/DailyReportsOperations.ascx_rdpR

And the RadDatePicker cannot be used.

I see that there are a lot of people with this problem, and no solution has been found for over a year now, that's weird


0
Pavel
Telerik team
answered on 09 Apr 2009, 02:15 PM
Hi guys,

Can you elaborate more on your scenario so we can try to reproduce the problem? Pasting some code/markup may be of great help for us. Also, please specify which version of the controls you are using.

Sincerely yours,
Pavel
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Louis Meijer
Top achievements
Rank 1
answered on 14 Apr 2009, 02:28 PM
Hi, I manged to reproduce the error in a test project. This occurs in 2008.1 and 2008.3 version of telerik controls.

1.Create a master page:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="RadDatePickerTest.Site1" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    
    <asp:ScriptManager ID="sm" runat="server" />
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    
    <div>
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
        
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

2.Add a webForm:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="RadDatePickerTest.WebForm1" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <telerik:RadAjaxManagerProxy ID="rmp1" runat="server">
        <AjaxSettings>
             <telerik:AjaxSetting AjaxControlID="btnLoad">  
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="pnlUC" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="rtb1">  
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="pnlUC" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>
    
      <div>  
         <telerik:RadToolBar ID="rtb1" runat="server" OnButtonClick="rtb1_Click">
            <Items>
                <telerik:RadToolBarButton id="rtBtn1" runat="server" Text="ClickMe" />
            </Items>
         </telerik:RadToolBar>
     </div>
     
     <div>
      <asp:Panel ID="pnlUC" runat="server">
      </asp:Panel>
     </div>
</asp:Content>


3.Create the first user control, this loads without problems:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UC.ascx.cs" Inherits="RadDatePickerTest.UC" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<div>
First User Control
<telerik:RadDatePicker Runat="server" id="rdpTest">
</telerik:RadDatePicker>
</div>

<asp:Panel ID="pnlDetails" runat="server" />

4.Create the second user control, this will be loaded as a child of the first user control in the pnlDetails panel:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UC2.ascx.cs" Inherits="RadDatePickerTest.UC2" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<div>
Second User Control
<telerik:RadDatePicker Runat="server" id="rdpTest2">
</telerik:RadDatePicker>
</div>

<asp:Panel ID="pnlDetails" runat="server" />

Here is the code behind for webForm1:

  public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (LatestLoadedControlName != null)
            {
                LoadUserControl(LatestLoadedControlName);
            }
        }

        private string LatestLoadedControlName
        {
            get
            {
                return (string)ViewState["LatestLoadedControlName"];
            }
            set
            {
                ViewState["LatestLoadedControlName"] = value;
            }
        }

        public void LoadUserControl(string controlName)
        {
            if (LatestLoadedControlName != null)
            {
                Control previousControl = pnlUC.FindControl(LatestLoadedControlName.Split('.')[0]);
                if (!Object.Equals(previousControl, null))
                {
                    this.pnlUC.Controls.Remove(previousControl);
                }
            }
            string userControlID = controlName.Split('.')[0];
            Control targetControl = pnlUC.FindControl(userControlID);
            if (Object.Equals(targetControl, null))
            {
                UserControl userControl = (UserControl)this.LoadControl(controlName);
                userControl.ID = userControlID.Replace("/", "").Replace("~", "");
                this.pnlUC.Controls.Add(userControl);
                LatestLoadedControlName = controlName;
            }
        }

        protected void rtb1_Click(object sender, RadToolBarEventArgs e)
        {
            if (e.Item.Text == "ClickMe")
            {
                LatestLoadedControlName = "UC.ascx";
                LoadUserControl(LatestLoadedControlName);
            }
        }
    }

Code for Base class for controls (BaseControl):

  public class BaseControl : UserControl
    {
        protected string controlData = string.Empty;
        protected Panel pnlDetails =  new Panel();

        protected override void OnLoad(System.EventArgs e)
        {
            base.OnLoad(e);
            this.pnlDetails.ID = "PANEL_WITH_DETAILS_CONTROLS";
            this.Controls.Add(pnlDetails);
           
        }

        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            //here I load the second user control
            //as a child of the first user control
            this.LoadDetails();
        }

        protected virtual void LoadDetails()
        {
            Control ctrl = null;
            string postBaclCtrlName = string.Empty;
            if ((this.Page != null) && (!string.IsNullOrEmpty(this.Page.Request.Params["__EVENTTARGET"])))
            {
                postBaclCtrlName = this.Page.Request.Params["__EVENTTARGET"];
            }

            if (!String.IsNullOrEmpty(postBaclCtrlName))
            {
                controlData = "~/UC2.ascx";
                ctrl = !string.IsNullOrEmpty(controlData) ? this.LoadControl(controlData) : null;
                if (ctrl != null)
                {
                    ctrl.ID = controlData;
                    if (controlData != null)
                    {
                        Control previousControl = pnlDetails.FindControl(controlData);
                        if (!Object.Equals(previousControl, null))
                        {
                            this.pnlDetails.Controls.Remove(previousControl);
                        }
                    }
                    this.pnlDetails.Controls.Add(ctrl);

                    this.Context.SetLastLoadedContextControl(controlData);
                }
            }
        }
    }

WebHelper:

public static class WebHelper
    {
         
        public
            static
            bool
            SetLastLoadedContextControl(this HttpContext context,
            string ctrl)
        {
            if (context == null)
                throw new ArgumentNullException("http context is null ");
            context.Session["lCtrl"] = ctrl;
            return true;
        }
        public
            static
            string
            GetLastLoadedContextControl(this HttpContext context)
        {
            if (context == null)
                throw new ArgumentNullException("http context is null ");

            return (string)context.Session["lCtrl"];
        }

        #region BaseContextData
     public
     static
     bool
     SetPreviousLoadedControl
     (
     this HttpContext context,
     string previousControl
     )
        {
            if (context == null)
                throw new ArgumentNullException("http context is null");


            context.Session["previousControl"] = previousControl;

            return true;
        }

        public
            static
            string
            GetPreviousLoadedControl
            (
            this HttpContext context
            )
        {
            if (context == null)
                throw new ArgumentNullException("http context is null");
            if (context.Session == null) return null;

            return (string)context.Session["previousControl"];
        }
        #endregion
    }

That's about it.  Hopefully someone will have a solution for this














0
Pavel
Telerik team
answered on 16 Apr 2009, 10:54 AM
Hello Louis,

In this case the error is caused by the ID you assign to your second control ("~/UC2.ascx"). This is not a valid ID in .Net. Try changing it so that it does not include characters such as "~" or ".". Here is you modified code which works on my end:

if (!String.IsNullOrEmpty(postBaclCtrlName)) 
    controlData = "~/UC2.ascx"
    ctrl = !string.IsNullOrEmpty(controlData) ? this.LoadControl(controlData) : null
    if (ctrl != null
    { 
        ctrl.ID = controlData.Replace("~/","").Replace(".ascx",""); 
        if (controlData != null
        { 
            Control previousControl = pnlDetails.FindControl(controlData); 
            if (!Object.Equals(previousControl, null)) 
            { 
                this.pnlDetails.Controls.Remove(previousControl); 
            } 
        } 
        this.pnlDetails.Controls.Add(ctrl); 
 
        this.Context.SetLastLoadedContextControl(controlData); 
    } 


Kind regards,
Pavel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Louis Meijer
Top achievements
Rank 1
answered on 16 Apr 2009, 11:32 AM
Indeed that was the solution I was looking for, thanks Pavel, I guess you can mark this topic as solved now.
http://msdn.microsoft.com/en-us/library/system.web.ui.control.id.aspx
Tags
Calendar
Asked by
Rafael Avila
Top achievements
Rank 1
Answers by
Missing User
Scott Bedard
Top achievements
Rank 1
Louis Meijer
Top achievements
Rank 1
Pavel
Telerik team
Share this question
or