Computing.Net > Forums > Programming > Web Part

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Web Part

Reply to Message Icon

Name: mariarajakumar
Date: November 16, 2006 at 21:59:52 Pacific
OS: Windows 2003
CPU/Ram: 3 Ghzt
Product: Intel
Comment:

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



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


PHP. Send Unix command Script to delete specific...



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Web Part

Web page question www.computing.net/answers/programming/web-page-question/2834.html

Adding a web site to search engines www.computing.net/answers/programming/adding-a-web-site-to-search-engines/5274.html

Web based scheduling program www.computing.net/answers/programming/web-based-scheduling-program/5504.html