Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello Friends,
I have sharepoint services running on my Windows 2003 R2 Server. From VS2005, I created a sample web part like below (just to see how it looks).
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebPartPages;
using System.Reflection;[assembly: AssemblyKeyFile("sample.snk")]
namespace WebPartLibrary1
{/// <summary>
/// Description for WebPart1.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:WebPart1 runat=server></{0}:WebPart1>"),
XmlRoot(Namespace = "WebPartLibrary1")]
public class WebPart1 : Microsoft.SharePoint.WebPartPages.WebPart
{
private const string defaultText = "";private string text = defaultText;
[Browsable(true),
Category("Miscellaneous"),
DefaultValue(defaultText),
WebPartStorage(Storage.Personal),
FriendlyName("Text"),
Description("Text Property")]
public string Text
{
get
{
return text;
}set
{
text = value;
}
}/// <summary>
/// Constructor for the class.
/// </summary>
public WebPart1()
{
this.Title = "This is a test web part";
}protected override void RenderWebPart(HtmlTextWriter output)
{
output.Write(SPEncode.HtmlEncode(Text));
//Create a Label
Label testLabel = new Label();
//Write the Text
testLabel.Text = "Hello World";
//Add the label control to the page
this.Controls.Add(testLabel);
testLabel.RenderControl(output);
}
}
}and my dwp file look like this
<?xml version="1.0" encoding="utf-8"?>
<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2" >
<Title>WebPart1</Title>
<Description>WebPart1.</Description>
<Assembly>WebPartLibrary1</Assembly>
<TypeName>WebPartLibrary1.WebPart1</TypeName>
</WebPart>I made "safe control" entry in the web.config file (c:\inetpub\wwwroot) like below....
<SafeControl Assembly="WebPartLibrary1" Namespace="WebPartLibrary1" TypeName="*" Safe="True" />Also copied the WebPartLibrary1.dll to the c:\windows\assembly (GAC).
Still when I try to drag the web part in a wep part page... I get error like
below..."Web Part or Web Form Control on this Web Part Page cannot be displayed or imported because it is not registered on this site as safe."
I have even reinstalled IIS and Sharepoint Servies. My sharepoint runs as (All Unassigned)".
Can any body tell me what could be the reason for error and how to fix it. I am really struck up with this error.
Thanks in Advance.
TMRK
T.Maria Raja Kumar

![]() |
PHP. Send Unix command
|
Script to delete specific...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |