Using RadDatePicker in Sharepoint WebPart popup doesn't work

2 posts, 0 answers
  1. Marshall Scipio
    Marshall Scipio avatar
    2 posts
    Member since:
    May 2006

    Posted 09 Dec 2010 Link to this post

    I have followed the example that was laid out in previous posts of how to integrate RadControls into Sharepoint and basically, they compile and everything, but when I go to display the webpart, anything that needs to 'fire' doesn't work, e.g. buttons, actions, etc.

    So for purposes of demonstrations, I have stripped down to a very basic webpart that simply has only one RadDatePicker in it.

    using System;
    using System.Runtime.InteropServices;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Serialization;
      
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.WebControls;
    using Microsoft.SharePoint.WebPartPages;
      
    using Telerik.Web.UI;
      
    namespace InternalControls.WebParts.RadControlTest
    {
        [Guid("8f913f14-3a18-4287-8444-401611d3cc1f")]
        public class WebPart1 : System.Web.UI.WebControls.WebParts.WebPart
        {
            public WebPart1()
            {
            }
      
            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
                Page.ClientScript.RegisterStartupScript(typeof(WebPart1), this.ID, "_spOriginalFormAction = document.forms[0].action;_spSuppressFormOnSubmitWrapper=true;", true);
                if (this.Page.Form != null)
                {
                    string formOnSubmitAtt = this.Page.Form.Attributes["onsubmit"];
                    if (!string.IsNullOrEmpty(formOnSubmitAtt) && formOnSubmitAtt == "return _spFormOnSubmitWrapper();")
                    {
                        this.Page.Form.Attributes["onsubmit"] = "_spFormOnSubmitWrapper();";
                    }
                }
      
                ScriptManager sm = ScriptManager.GetCurrent(this.Page);
      
                if (sm == null)
                {
                    sm = new RadScriptManager();
      
                    Controls.AddAt(0, sm);
                }
            }
      
            protected override void OnLoad(EventArgs e)
            {
                base.OnLoad(e);
                Panel panel = new Panel();
                panel.ID = "Panel1";
                this.Controls.Add(panel);
      
                RadDatePicker rdp = new RadDatePicker();
                rdp.PopupDirection = DatePickerPopupDirection.BottomRight;
                rdp.Calendar.Enabled = true;
      
                panel.Controls.Add(rdp);
                RadAjaxManager ajaxManager = RadAjaxManager.GetCurrent(this.Page);
                if (ajaxManager == null)
                {
                    ajaxManager = new RadAjaxManager();
                    ajaxManager.ID = "RadAjaxManager1";
                    Controls.Add(ajaxManager);
                    this.Page.Items.Add(typeof(RadAjaxManager), ajaxManager);
                }
                ajaxManager.AjaxSettings.AddAjaxSetting(rdp, panel);
            }
        }
    }


    As I said, it will compile and deploy, but when the webpart surfaces the popup button for the calendar doesn't work.  In other words clicking on the popup button does nothing, where as if this were not in a webpart the calendar would be displayed.

    Can anyone please help me with this, I have been trying various things for several days.

    Thanks,

    Marshall
  2. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 11 Dec 2010 Link to this post

    Hello Marshall,

    Try changing the following line:

    Controls.AddAt(0, sm); 

    to:
    this.Page.Form.Controls.AddAt(0, scriptManager);

    and make sure that you have the RadScriptManager handler registered in the web.config for the MOSS applciation:
    http://www.telerik.com/help/aspnet-ajax/radscriptmanager.html

    Hope it helps.

    Greetings,
    Tsvetoslav
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top