sharepoint2007 webparts demo is not working

6 posts, 0 answers
  1. Greg
    Greg avatar
    12 posts
    Member since:
    Jul 2008

    Posted 02 Sep 2009 Link to this post

    Hi,
    I'm using the example you have..
    "Create an AJAX-enabled Sharepoint WEbPart tht uses RadControls"
    http://www.telerik.com/help/aspnet-ajax/create-ajax-enabled-sharepoint-webpart-radcontrols.html

    ... and it is not recognizing Telerick Web UI.

    AJAX is installed and configured on the MOSS.
    RadControls have been deployed to the SharePoint Server.

    I'm following the instructions for VS2008.  Using Team Edition.
    I'm also converting this to VB which isn't the issue.

    When I tried to create the Rad ScriptManager it did not recognize it. Smart Type or otherwise.
    Tools have been registered as well.


    Is there something missing to this example that you have given?
    I'm not seeing anything, but the creation of the webpart in the example, so how is it recognizing the Telerik UI.
    Webconfig has http handlers, etc... as they should.

    I have what you see on this page except it is in VB and again that isn't the issue.
    When I try to declare RadTree or RadScriptManager they are not being recognized.

    Thanks!

    Thanks!
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 04 Sep 2009 Link to this post

    Hi Greg,

    You need to add a reference to the Telerik.Web.UI assembly to your project. Then you import the Telerik.Web.UI namespace to your vb page and start using the RadControls.


    Greetings,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

  3. Greg
    Greg avatar
    12 posts
    Member since:
    Jul 2008

    Posted 04 Sep 2009 Link to this post

    Ok.  Let me make sure we are on the same page.

    So you are saying open up VS2008.
    Create the Webpart in and of itself as it is in the example.
    So I'm not creating a project and then adding adding a WebPart from the right-click of that project or anything correct???

    I have to ask this because someone else here is claiming the WebPart needs to be added INSIDE a solution with another project.
    It is working, but I get the feeling it might cause problems later on and is not the way to go.

    I've been down a similar road and don't want someone to claim a fix that is much different than what you specifiy.

    http://www.telerik.com/help/aspnet-ajax/create-ajax-enabled-sharepoint-webpart-radcontrols.html

    Part 1

    This article shows how to create an AJAX-enabled SharePoint WebPart that uses RadControls.

    All of that was done by someone else.   Here is where I enter the picture.

    • Create a new WebPart project in Visual Studio:



    I followed this...

     

  4. Add the following code:

      Copy Code
    protected override void OnInit(EventArgs e)
    {
       
    base.OnInit(e);
       Page.ClientScript.RegisterStartupScript(
    typeof(Web_Part1), 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();";
           }
       }
    }
    As explained in the linked blog post, we need this code to get ASP.NET AJAX working properly. You need to pass the typeof of the current WebPart to the RegisterStartupScript method.
  5. To use ASP.NET AJAX, you need a ScriptManager control on the page. The blog post explained how to add the ScriptManager to a SharePoint MasterPage. Alternatively, you can add the ScriptManager from the code of the WebPart itself as demonstrated here. Add the following to the OnInit method:
      Copy Code
    ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
    if (scriptManager == null)
    {
       scriptManager =
    new RadScriptManager(); 
       
    this.Page.Form.Controls.AddAt(0, scriptManager);
    }

    It’s important to note that the ScriptManager is created during the Init event. Creating it in the CreateChildControls method may cause problems as this method is sometimes called too late in the Page’s lifecycle.  We can use the RadScriptManager instead of the regular ScriptManager. You can read more about the RadScriptManager at http://www.telerik.com/help/aspnet-ajax/radscriptmanager.html.
  6. For the RadScriptManager to work, you need to register its HttpHandler. To do this, add the following in the <httpHandlers> section of SharePoint’s web.config:
      Copy Code
    <add verb="*" path="Telerik.Web.UI.WebResource.axd"
    type="Telerik.Web.UI.WebResource, Telerik.Web.UI" />
  7. This is all the preparation you need to start using RadControls in your WebParts. Simply override the OnLoad method and add your controls there:
      Copy Code
    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();
    }

    There is one difference from a non-SharePoint scenario. When you are using RadAjaxManager, you need to call the following code upon creating it:
      Copy Code
    this.Page.Items.Add(typeof(RadAjaxManager), ajaxManager);
  8. You can now use the Deploy Web Part option in the Build menu to build and deploy the Web Part to SharePoint.  You should now be able to add the Web Part to your pages:
  9. The only time Telerik.Web.UI is reference is in placing it in the sharepoint webconfig.
    I tried to add reference, but it wouldn't recognize the dll.  It recognizes openaccess and reports, but not the web.ui.
    I didn't set up the sharepoint, so I don't know if this is an environment issue or not, but right now it is believe not to be because someone is walking away claiming to do it another way.

    In this other fashion.  There are TWO projects in the solution.  For me this doesn't sound right whether it works or not.
    It is like having a to have user control that requires it shares the solution with another project.

    Here is what we have.  As you can see Project Two References Project One.
    I don't think this is what you are describing and I'd like a full project code, if possible, to go by.
    Nothing complicated.  Just a simple WebPart for Sharepoint and this would include the import/using statements depending on the language.   I'd rather get it right then pushing something out to quick only for it to become a maintenance nightmare.

    Solution (2 projects)

    - Project One
    --- Properties
    ----- AssemblyInfo.cs
    --- References
    ----- System
    ----- System.Configuration
    ----- System.Core
    ----- System.Data
    ----- System.Data.DataSetExtensions
    ----- System.Drawing
    ----- System.EnterpriseServices
    ----- System.Web
    ----- System.Web.Extensions
    ----- System.Web.Mobile
    ----- System.Xml
    ----- System.Xml.Linq
    ----  Telerik.Web.UI
    --- Deafult.aspx
    ----- Default.aspx.cs
    ----- Default.aspx.designer.cs
    ----- Web.config

    - Project Two
    --- Properties
    ----- AssemblyInfo.cs
    ----- Project Two.snk
    --- References
    ----- Microsoft.Sharepoint
    --- Project One
    ----- System
    ----- System.Web
    ----- System.Web.Extensions
    ----- System.Xml
    ----- Telerik.Web.UI

    --- WebPart1
    ----- WebPart1.cs
    ----- WebPart1.webpart
    ----- WebPart1.xm.

    NOTE:
    I tried to copy this in as a table, but I keep getting errors.
    I left the table below to show you.  This had the borders all off in Word03.
    Still some came in with borders.  I tried to edit table/cell but "Done, with errors on page" appears in the lower left status bar of IE.




    Solution (2 projects)

    -

    Project One

     

    -

    Properties

     

     

    -

    AssemblyInfo.cs

     

    -

    References

     

     

    -

    System

     

     

    -

    System.Configuration

     

     

    -

    System.Core

     

     

    -

    System.Data

     

     

    -

    System.Data.DataSetExtensions

     

     

    -

    System.Drawing

     

     

    -

    System.EnterpriseServices

     

     

    -

    System.Web

     

     

    -

    System.Web.Extensions

     

     

    -

    System.Web.Mobile

     

     

    -

    System.Xml

     

     

    -

    System.Xml.Linq

     

     

    -

    Telerik.Web.UI

     

    -

    Deafult.aspx

     

     

    -

    Default.aspx.cs

     

     

    -

    Default.aspx.designer.cs

     

     

    -

    Web.config

     

    Project Two

     

    -

    Properties

     

     

    -

    AssemblyInfo.cs

     

     

    -

    Project Two.snk

     

    -

    References

     

     

    -

    Microsoft.Sharepoint

     

     

    -

    Project One

     

     

    -

    System

     

     

    -

    System.Web

     

     

    -

    System.Web.Extensions

     

     

    -

    System.Xml

     

     

    -

    Telerik.Web.UI

     

    -

    WebPart1

     

     

    -

    WebPart1.cs

     

     

    -

    WebPart1.webpart

     

     

    -

    WebPart1.xm.



  • Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 08 Sep 2009 Link to this post

    Hi Greg,

    You can find attached a simple web part.

    All the best,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  • Greg
    Greg avatar
    12 posts
    Member since:
    Jul 2008

    Posted 14 Sep 2009 Link to this post

    Ok.  I'm narrowing this down by process of exposure.  I comment out all the Rad references and with each successful build->deploy->test of launching the site I go back and expose more.

    It seems as soon as I add Radcontrols to the panel I get this error.

    RadUpload Ajax callback error. Source url returned invalid content:
    This error panal that comes up is modal and doesn't fit entirely in my screen.


    Is this pointing to a webconfig issue with httphandlers????
  • Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 15 Sep 2009 Link to this post

    Hi Greg,

    Please check the Configuration help topic.

    All the best,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  • Back to Top