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

SharePoint Web Part with Rad Controls is NOT working

1 Answer 212 Views
Sharepoint Integration
This is a migrated thread and some comments may be shown as answers.
Sai
Top achievements
Rank 1
Sai asked on 21 Jan 2009, 10:31 PM
Hi,

Recently, we bought ASP.NET AJAX telerik controls. Installed Telerik Controls Q3 2008 (default installation) in a server where MOSS is installed and now, wanted to use these controls in the SharePoint sites. I followed the guidelines for usage of these controls but not very much clear for me to use from SharePoint web part or any other component. To test the usage, I did a sample but facing problem.

I created a web part for MOSS by following the guidelines provided at http://www.telerik.com/help/aspnet-ajax/create-ajax-enabled-SharePoint-webpart-radcontrols.html

Note:
I used Visual Studio 2005 with extensions for Windows SharePoint Services.
In the Visual Studio 2005, I created a project for SharePoint Web Part and used the code from your guidelines.

Steps followed for Telerik Controls Installation and web part development:
a. Telerik Controls installation in the SharePoint environment:  I installed the telerik controls by using set up Automatic Install RadControls_for_ASP.NET_AJAX_2008_3_1125_dev.exe.
b. Telerik installed the controls in the default location C:\Program Files\Telerik\RadControls for ASPNET AJAX Q3 2008
c. Deployed the Telerik.Web.UI.dll in GAC from C:\Program Files\Telerik\RadControls for ASPNET AJAX Q3 2008\Bin folder.
d. Followed the guidelines mentioned in http://www.telerik.com/help/aspnet-ajax/moss-install-aspnet-ajax.html  and http://www.telerik.com/help/aspnet-ajax/moss-deploying-radcontrols.html.
e. Developed the web part (code provided below).
f. Deployed the web part  (web part created the required safecontrol entry for web part dll).

Questions:
The web part is using RadTreeView control. On clicking the tree node "What's the time?", the web part should show the current time in the place of "This is a label".  But, the time is not shown and not able to click the tree node.  I checked all the configuration settings for ASP.NET Ajax and also guildelines for Telerik control usage.  Not sure why this web part is not working?

Any help is appreciated and blocked on usage of these controls enterprize level.

Here is my code:

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 ITSUS_ITrInno_TelerikWebPart
{
    [Guid("e57fdda1-ce58-4d9d-b66a-dfdadd0fea52")]
    public class TelerikWebPart : System.Web.UI.WebControls.WebParts.WebPart
    {
        public TelerikWebPart()
        {
        }

        Label label;

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            Page.ClientScript.RegisterStartupScript(typeof(TelerikWebPart), 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 scriptManager = ScriptManager.GetCurrent(this.Page);
            if (scriptManager == null)
            {
                scriptManager = new RadScriptManager();
                this.Page.Form.Controls.Add(scriptManager);
                // this.Page.Form.Controls.AddAt(0,scriptManager);
            }
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            Panel panel = new Panel();
            panel.ID = "Panel1";
            this.Controls.Add(panel);
            RadTreeView treeView = new RadTreeView();
            treeView.ID = "RadTreeView1";
            treeView.Nodes.Add(new RadTreeNode("What's the time?"));
            treeView.NodeClick += new RadTreeViewEventHandler(treeView_NodeClick);
            panel.Controls.Add(treeView);
            label = new Label();
            label.Text = "This is a label";
            panel.Controls.Add(label);
            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(treeView, panel);
        }

        void treeView_NodeClick(object sender, RadTreeNodeEventArgs e)
        {
            label.Text = DateTime.Now.ToLongTimeString();
        }

        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            // TODO: add custom rendering code here.
            // Label label = new Label();
            // label.Text = "Hello World";
            // this.Controls.Add(label);
        }
    }
}

1 Answer, 1 is accepted

Sort by
0
Dimitar Milushev
Telerik team
answered on 26 Jan 2009, 11:48 AM
Hello Sai,

I tested your Web Part code and it seems to work as expected. You should make sure that everything is configured properly in your Sharepoint installation - you have the MOSS Service Pack installed, the AJAX extensions are installed etc. It's a lengthy process and it's easy to miss a step.

Greetings,
Dimitar Milushev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Sharepoint Integration
Asked by
Sai
Top achievements
Rank 1
Answers by
Dimitar Milushev
Telerik team
Share this question
or