Hello I just created a helloworld web part but I am having problems with
installation.

It says that the webpart is not safe.

I see many web.configs on my machine and I dont know which one to add it, I
added this code to the onte that is in Inetpub\wwwroot but I still get the
error.

<SafeControl Assembly="LibreriaDeWebParts"
Namespace="MyWebPart1"
TypeName="*" Safe="True" />

This is the code

using System;

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;

namespace MyWebPart1

{

/// <summary>

/// Description for WebPart1.

/// </summary>

[DefaultProperty("Text"),

ToolboxData("<{0}:WebPart1 runat=server></{0}:WebPart1>"),

XmlRoot(Namespace="LibreriaDeWebParts")]

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>

/// This method gets the custom tool parts for this Web Part by overriding
the

/// GetToolParts method of the WebPart base class. You must implement

/// custom tool parts in a separate class that derives from

/// Microsoft.SharePoint.WebPartPages.ToolPart.

/// </summary>

///<returns>An array of references to ToolPart objects.</returns>

// public override ToolPart[] GetToolParts()

// {

// ToolPart[] toolparts = new ToolPart[2];

// WebPartToolPart wptp = new WebPartToolPart();

// CustomPropertyToolPart custom = new CustomPropertyToolPart();

// toolparts[0] = wptp;

// toolparts[1] = custom;

// return toolparts;

// }


/// <summary>

/// Render this Web Part to the output parameter specified.

/// </summary>

/// <param name="output"> The HTML writer to write out to </param>

protected override void RenderWebPart(HtmlTextWriter output)

{

output.Write(SPEncode.HtmlEncode(Text));

//Create a Lable

Label myLabel = new Label();

//Write the Text

myLabel.Text = "Hello World";

//Add the lable control to the page

this.Controls.Add(myLabel);

//Render the Html output

myLabel.RenderControl(output);

}

}

}

Re: WebPart Installation. by Mike

Mike
Thu Jul 28 23:28:26 CDT 2005

We have a special subnewsgroup for WSS Programming questions which includes
problems involved in the *creation* of web parts as well as usage of web
services and other coding issues.

It's at

microsoft.public.sharepoint.windowsservices.development

Please post this question there.

[We're also grateful if future WSS Programming postings go only there so we
can keep up the clear split between the two newsgroups and avoid duplication
of effort.]

Thanks.

Mike Walsh, Helsinki, Finland
WSS FAQ http://wss.collutions.com
please reply to the newsgroup only

"Luis Esteban Valencia" <levalencia@avansoft.com> wrote in message
news:eJCbf83kFHA.1416@TK2MSFTNGP09.phx.gbl...
> Hello I just created a helloworld web part but I am having problems with
> installation.
>
> It says that the webpart is not safe.
>
> I see many web.configs on my machine and I dont know which one to add it,
> I
> added this code to the onte that is in Inetpub\wwwroot but I still get
> the
> error.
>
> <SafeControl Assembly="LibreriaDeWebParts"
> Namespace="MyWebPart1"
> TypeName="*" Safe="True" />
>
> This is the code
>
> using System;
>
> 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;
>
> namespace MyWebPart1
>
> {
>
> /// <summary>
>
> /// Description for WebPart1.
>
> /// </summary>
>
> [DefaultProperty("Text"),
>
> ToolboxData("<{0}:WebPart1 runat=server></{0}:WebPart1>"),
>
> XmlRoot(Namespace="LibreriaDeWebParts")]
>
> 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>
>
> /// This method gets the custom tool parts for this Web Part by overriding
> the
>
> /// GetToolParts method of the WebPart base class. You must implement
>
> /// custom tool parts in a separate class that derives from
>
> /// Microsoft.SharePoint.WebPartPages.ToolPart.
>
> /// </summary>
>
> ///<returns>An array of references to ToolPart objects.</returns>
>
> // public override ToolPart[] GetToolParts()
>
> // {
>
> // ToolPart[] toolparts = new ToolPart[2];
>
> // WebPartToolPart wptp = new WebPartToolPart();
>
> // CustomPropertyToolPart custom = new CustomPropertyToolPart();
>
> // toolparts[0] = wptp;
>
> // toolparts[1] = custom;
>
> // return toolparts;
>
> // }
>
>
> /// <summary>
>
> /// Render this Web Part to the output parameter specified.
>
> /// </summary>
>
> /// <param name="output"> The HTML writer to write out to </param>
>
> protected override void RenderWebPart(HtmlTextWriter output)
>
> {
>
> output.Write(SPEncode.HtmlEncode(Text));
>
> //Create a Lable
>
> Label myLabel = new Label();
>
> //Write the Text
>
> myLabel.Text = "Hello World";
>
> //Add the lable control to the page
>
> this.Controls.Add(myLabel);
>
> //Render the Html output
>
> myLabel.RenderControl(output);
>
> }
>
> }
>
> }
>
>