Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to create Web Part properties. Below is my code :

using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace SP2010VisualWebPart.AmazingVisualWebPart
{
    [ToolboxItemAttribute(false)]
    public class AmazingVisualWebPart : WebPart
    {

        private PrettyColors _textColor = PrettyColors.Black;


        public PrettyColors textColor
        {
            get { return _textColor; }
            set { _textColor = value; }
        }


        private const string _ascxPath = @"~/_CONTROLTEMPLATES/SP2010VisualWebPart/AmazingVisualWebPart/AmazingVisualWebPartUserControl.ascx";


        private AmazingVisualWebPartUserControl userControlReference;

        protected override void CreateChildControls()
        {
            Control control = Page.LoadControl(_ascxPath);
            Controls.Add(control);


            userControlReference = (AmazingVisualWebPartUserControl)control;
            userControlReference.SetWebPartReference(this);
        }

        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            userControlReference.SetTextColor(this._textColor.ToString());
        }

        public override EditorPartCollection CreateEditorParts()
        {

            List<EditorPart> editorParts = new List<EditorPart>(1);
            EditorPart editorPart = new AmazingVisualEditorPart.AmazingVisualEditorPart();
            editorPart.ID = this.ID + "_EditorPart";
            editorParts.Add(editorPart);

            return new EditorPartCollection(base.CreateEditorParts(), editorParts);
        }
    }
}

Below is the error I am getting

The type or namespace name 'List' could not be found (are you missing a using directive or an assembly reference?)

How can i debug this?

share|improve this question
    
By the way I have the exampel from this URL packtpub.com/sites/default/files/… –  Newbie Jul 31 '12 at 19:51
add comment

1 Answer

up vote 0 down vote accepted

Add using System.Collections.Generic; at the top of your code. You haven't imported the namespace.

http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx

(Or, in VS2010, right click on the List<T> object, hover on resolve, and click "add using statement")

share|improve this answer
    
Thanks rjcup3 allmost there, but still got this error The type or namespace name 'AmazingVisualEditorPart' could not be found (are you missing a using directive or an assembly reference?) –  Newbie Jul 31 '12 at 20:38
    
Did you create a class for that? Is it in a different project? The rest of your code is referencing an AmazingVisualWebPart not a class named AmazingVisualEditorPart. –  RJ Cuthbertson Jul 31 '12 at 20:41
    
Hi rjcup3 Yes you are right - its in a diffent project - Sorry my mistake –  Newbie Jul 31 '12 at 21:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.