Deploying RadControls into MOSS 2007 WebParts

5 posts, 0 answers
  1. John
    John avatar
    6 posts
    Member since:
    Apr 2008

    Posted 28 May 2008 Link to this post

    Hi All,
    I'm working on a project where deployment of RadControls into SharePoint 2007 WebParts is essential.  I've followed the steps on the documentation site (http://www.telerik.com/help/aspnet-ajax/moss-deploying-radcontrols.html), but I am getting the following permissions error when I load my user control webpart into a web part zone: 

    CreateChildControls_Exception: "Access to the path 'C:\Inetpub\wwwroot\wss\VirtualDirectories\80\UserControls\myTreeControl.ascx' is denied."

    I'm not sure if additional configuration apart from what is included in the documentation is neccessary.  Please help if you can.

    Thanks,
    John P.
  2. John
    John avatar
    6 posts
    Member since:
    Apr 2008

    Posted 28 May 2008 Link to this post

    I've fixed the previous problem, but now when the web part loads, there is no ajax functionality.  Every event fires a full page refresh.  Any ideas why this is happening?

  3. John
    John  avatar
    3 posts
    Member since:
    May 2008

    Posted 28 May 2008 Link to this post

    Here is my code.  When I run the web part on SharePoint everything works except the ajax post back functionality and I get the following error message displaying below the control: 

    CreateChildControls_Exception: The control with ID 'UpdatePanel1' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.

    This would lead me to believe that for some reason my ScriptManager is not doing its job.  Any suggestions?


    using

    System;

    using

    System.Data;

    using

    System.Configuration;

    using

    System.Web;

    using

    System.Web.Security;

    using

    System.Web.UI;

    using

    Microsoft.SharePoint.WebPartPages;

    using

    System.Web.UI.WebControls;

    using

    System.Web.UI.HtmlControls;

    using

    System.IO;

     

    namespace

    jpTelerikDeployment

    {

    //Set the inheritance of the class to WebPart

    public class MyInformation : WebPart

    {

    //The control object that we will be loading our user control into

    private Control _control;

    private string _exceptions = String.Empty;

    //These two properties determine the location from which to load the associated Web Control ASCX file.

    protected string UserControlPath = @"~/UserControls/";

    protected string UserControlFileName = "jpTelerikDeploymentControl.ascx";

    protected override void OnInit(EventArgs e)

    {

    //Test to see if there is currently a script manager on the site

    if (ScriptManager.GetCurrent(this.Page) == null)

    {

    //If there is not, add one

    ScriptManager scriptHandler = new ScriptManager();

    scriptHandler.ID =

    "scriptHandler";

    this.Controls.Add(scriptHandler);

    }

    base.OnInit(e);

    }

    protected override void CreateChildControls()

    {

    //creates the base to build child controls

    base.CreateChildControls();

    //Fix for the UpdatePanel postback behaviour.

    EnsurePanelFix();

    try

    {

    //Load the control path string

    _control =

    this.Page.LoadControl(UserControlPath + UserControlFileName);

    // add it to controls collection to wire up events

    this.Controls.Add(_control);

    }

    catch (Exception CreateChildControls_Exception)

    {

    _exceptions +=

    "CreateChildControls_Exception: " + CreateChildControls_Exception.Message;

    }

    }

    protected override void RenderContents(HtmlTextWriter writer)

    {

    try

    {

    base.RenderContents(writer);

    }

    catch (Exception RenderContents_Exception)

    {

    _exceptions +=

    "RenderContents_Exception: " + RenderContents_Exception.Message;

    }

    finally

    {

    if (_exceptions.Length > 0)

    {

    writer.WriteLine(_exceptions);

    }

    }

    }

    private void EnsurePanelFix()

    {

    if (this.Page.Form != null)

    {

    String fixupScript = @"

    _spBodyOnLoadFunctionNames.push(""_initFormActionAjax"");

    function _initFormActionAjax()

    {

    if (_spEscapedFormAction == document.forms[0].action)

    {

    document.forms[0]._initialAction =

    document.forms[0].action;

    }

    }

    var RestoreToOriginalFormActionCore =

    RestoreToOriginalFormAction;

    RestoreToOriginalFormAction = function()

    {

    if (_spOriginalFormAction != null)

    {

    RestoreToOriginalFormActionCore();

    document.forms[0]._initialAction =

    document.forms[0].action;

    }

    }"

    ;

    ScriptManager.RegisterStartupScript(this, typeof(MyInformation), "UpdatePanelFixup",

    fixupScript,

    true);

    }

    }

    }

    }

  4. Rosen
    Admin
    Rosen avatar
    3237 posts

    Posted 30 May 2008 Link to this post

    Hello John ,

    Can you please try to add the ScriptManager to the page's Form controls collection instead of the webpart's controls collection. Similar to this:

    this.Page.Form.Controls.Add(scriptHandler);  

    If you continue to experience difficulties please sent us (attached to a formal ticket) a working project in which this behavior can be observed. Thus we will do our best to provide more to-the-point answer/solution.

    Best regards,
    Rosen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. John
    John avatar
    6 posts
    Member since:
    Apr 2008

    Posted 30 May 2008 Link to this post

    Rosen,
    Thanks for the help.  That actually fixed the problem.  I was also having issues adding two ajax enabled web parts to the same page, but that has been fixed as well.  Thanks again.

    John P
Back to Top