Sharepoint integration examples

10 posts, 0 answers
  1. Larkin Young
    Larkin Young avatar
    141 posts
    Member since:
    Feb 2005

    Posted 13 Jul 2005 Link to this post

    This may not be something many customers might find useful, but I am currently doing some custom Web Part development in Sharepoint Portal Server 2003 and was wondering if anyone might find the information useful--I could post some examples of how I integrated r.a.d controls in Sharepoint, such as r.a.d. editor, r.a.d. treeview, r.a.d. menu, and r.a.d. grid (I may be working with some additional controls soon).

    If anyone has any interested in this information let me know and I will gladly adapt some examples to post--with Telerik's permission, of course ;-)
  2. Fredrick Zilz
    Fredrick Zilz avatar
    11 posts
    Member since:
    Mar 2005

    Posted 19 Jul 2005 Link to this post

     I would love to see some examples of the RAD controls integrated into Web Parts.  I am just starting to develop some web parts for internal use on our Sharepoint services sites.  I would love the jump start.
  3. Larkin Young
    Larkin Young avatar
    141 posts
    Member since:
    Feb 2005

    Posted 20 Jul 2005 Link to this post

    Not a problem, I am still finishing up some of the work, but I will post some examples as soon as I can. In the meantime if you have any questions I would be glad to help out.

    - Larkin

  4. Fredrick Zilz
    Fredrick Zilz avatar
    11 posts
    Member since:
    Mar 2005

    Posted 20 Jul 2005 Link to this post

    Just curious, do you drop all of your dlls in the GAC for your webserver or have you been successful in adding them to the bin folder and doing custom security?

    I plan to create a web part that pull sales data from my sql server and displays the data and a pie chart for the top ten customers. I plan to use the Rad chart control, but as I would normally drop the chart on an aspx page in VS.net, I am a little unclear on what I need to do for a web part to use the control. So any examples you have of using the controls in a webpart would be appreciated.


    Also do you need to add teh Radcontrol (radchart) dll to the savecontrol  section of the web.config?  I am getting an "cannot be displayed or imported because it is not registered on this site as safe."  for my webpart even though my dll is registered in my web.config and I dropped my dll in the GAC.  So I am wondering if any of the assemblies referenced need to be included in the safecontrols.

    Thanks in advance for your help.
  5. Fredrick Zilz
    Fredrick Zilz avatar
    11 posts
    Member since:
    Mar 2005

    Posted 21 Jul 2005 Link to this post

    Here is my attempt to just get the chart control working in a web part.  What am I doing wrong.  This compiles in VS.net without issue, but when I add the part to a sharepoint page, I get the "Error 
    The "TopTenChart" Web Part appears to be causing a problem. "
    error page.

    <code>
    Imports System
    Imports System.ComponentModel
    Imports System.Data
    Imports System.Data.SqlClient
    Imports System.Web.UI
    Imports System.Web.UI.WebControls
    Imports System.Xml.Serialization
    Imports System.Drawing
    Imports Microsoft.SharePoint
    Imports Microsoft.SharePoint.Utilities
    Imports Microsoft.SharePoint.WebPartPages
    Imports Telerik.WebControls
    Imports Microsoft.ApplicationBlocks.Data

    <DefaultProperty("Text"), ToolboxData("<{0}:TopTenChart runat=server></{0}:TopTenChart>"), XmlRoot(Namespace:="SalesDataWPLibrary")> _

    Public Class TopTenChart
    Inherits Microsoft.SharePoint.WebPartPages.WebPart

    ' Private Shared colors As Color() = {Color.AliceBlue, Color.AntiqueWhite, Color.Aqua, Color.Aquamarine, Color.Azure, Color.CornflowerBlue, Color.SteelBlue}

    Dim chart1 As Telerik.WebControls.RadChart
    Dim s, s1 As ChartSeries
    Private Const _defaultText As String = "TopTen"
    Dim _text As String = _defaultText
    <Browsable(
    True), Category("Miscellaneous"), DefaultValue(_defaultText), WebPartStorage(Storage.Personal), FriendlyName("Text"), Description("Text Property")> _

    Property [Text]() As String

    Get

    Return _text

    End Get

    Set(ByVal Value As String)

    _text = Value

    End Set

    End Property

    'Render this Web Part to the output parameter specified.

    Protected Overrides Sub CreateChildControls()

    chart1 = New RadChart

    chart1.ChartSeriesCollection.Clear()

    s = New ChartSeries("GDP", Color.Red, ChartSeriesType.Line)

     s.ShowLabels = True

    s.AddItem(1)

    s.AddItem(1.5)

    s.AddItem(2.0)

    s.AddItem(2.5)

    s.AddItem(3.5)

    chart1.AddChartSeries(s)

    s1 = New ChartSeries("GNP", Color.Blue, ChartSeriesType.Line)

    s1.ShowLabels = True

    s1.AddItem(2)

    s1.AddItem(3)

    s1.AddItem(3.5)

    s1.AddItem(4)

    s1.AddItem(4.5)

    chart1.AddChartSeries(s1)

     chart1.Title1.Text = "Growth Indicators"

    chart1.Title1.TextColor = Color.BlueViolet

    chart1.XAxis.Label.Text = "Years"

    chart1.XAxis.AxisColor = Color.Yellow

    chart1.XAxis.Label.TextColor = Color.Brown

    chart1.XAxis.AxisWidth = 2

    chart1.YAxis.Visible = True

    chart1.YAxis.Label.Text = "%"

    chart1.YAxis.AxisColor = Color.Yellow

    chart1.YAxis.Label.TextColor = Color.Brown

    chart1.YAxis.AxisWidth = 2

    Controls.Add(chart1)

    End Sub

    Protected
    Overrides Sub RenderWebPart(ByVal output As System.Web.UI.HtmlTextWriter)

    RenderChildren(output)

    output.Write(SPEncode.HtmlEncode([Text]))

    'chart1.RenderControl(output)
    End Sub
    End Class
    </code>

  6. Larkin Young
    Larkin Young avatar
    141 posts
    Member since:
    Feb 2005

    Posted 21 Jul 2005 Link to this post

    Are you deploying your web part in a cab file? The easiest way is to include a SafeControls declaration section in your manifest.xml file so that the r.a.d. chart assembly is trusted by sharepoint.

  7. Fredrick Zilz
    Fredrick Zilz avatar
    11 posts
    Member since:
    Mar 2005

    Posted 21 Jul 2005 Link to this post

    I could try that, I have not been creating cab files, I have been manually editing the web.config, dropping the dll in the bin or GAC and placing the dwp in the wpcatalog folder. 

    I am no longer getting the "cannot be displayed or imported because it is not registered on this site as safe.", but I am now getting the more general  "Web Part appears to be causing a problem." error.   If I comment out the Controls.Add(chart1) My webpart renders without error, so I believe my control is listed as safe and my dwp is correct, but something is wrong with how I am using the chart control.

    Any help would be appreciated.
  8. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 25 Jul 2005 Link to this post

    Hi Frederick,

    You may try the following:

    • Copy RadControls folder in C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\TEMPLATE\LAYOUTS\. Then set the RadControlsDir property of r.a.d.chart to "~/_layouts/RadControls".
    • Set the UseSession property of r.a.d.chart to false because session state is disabled by default in SharePoint.
    • Make a "temp" folder in c:\inetpub\wwwroot. It is required by r.a.d.chart when session state is disabled.
    • Make sure you are instantiating r.a.d.chart and adding it in the Controls collection in CreateChildControls not in RenderWebPart.

    You can enable exception stacktrace in SharePoint to see verbose output of the error you are getting. Here is explained how.

    Kind Regards,

    Robert
    the telerik team

  9. Christopher Walker
    Christopher Walker avatar
    1 posts
    Member since:
    Aug 2005

    Posted 10 Feb 2006 Link to this post

    I would be very interested to see how you got the RAD Menu to work.  I have gotten the control to the point where I can get the top level menu to render but when you mouse over items in the top menu, a sub-menu does not drop down as you would expect.

    The relevant code:
      protected override void RenderWebPart(HtmlTextWriter output)
      {
       EnsureChildControls();
       RadMenu1.LoadContentFileAbsolutePath(Page.Server.MapPath(".\\menu.xml"));
       RadMenu1.RenderControl(output);
       output.Write(SPEncode.HtmlEncode(Text));
      }
      protected override void CreateChildControls()
      {
       base.CreateChildControls ();
       RadMenu1 = new Telerik.WebControls.RadMenu();
       Controls.Add(RadMenu1);
      }
  10. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 13 Feb 2006 Link to this post


    Hi Christopher,

    We've replied your support ticket but are pasting our reply here also:

    The problem in your case is that you are populating the menu in the RenderWebPart method which is too late considering it's lifecycle. You should move the call of RadMenu1.LoadContentFileAbsolutePath(Page.Server.MapPath(".\\menu.xml")); into your CreateChildControls method. Here is a code snippet which we typically send to clients who are trying to implement a SharePoint WebPart - the population code goes in CreateChildControls.

    public class MyWebPart : WebPart
    {
         protected override void CreateChildControls()
         {
               base.CreateChildControls();

               RadMenu menu = new RadMenu();
               menu.ID = "myMenu";
               /* populate your menu based on your requirements */
               menu.LoadContentFileAbsolutePath(Page.Server.MapPath(".\\menu.xml"));

               Controls.Add(menu);
         }

         protected override void RenderWebPart(HtmlTextWriter output)
         {
               EnsureChildControls();
               RenderChildren(output);
         }


    Regards,
    Albert
    the telerik team
Back to Top