Search code examples
c#asp.netsharepointvisual-studio-2012web-parts

Custom visual web part properties sharepoint


I'm having trouble creating visual web part properties in visual studio 2012.. I was refered to http://msdn.microsoft.com/en-us/library/ee231551.aspx, but then was unsuccessful..

looked in the Web part and found the .ascx, ascx.cs and the ascx.g.cs

I've been trying to find the webpart.cs file but then I cant. Is there a way I can create it or maybe I'm looking in the wrong place..


Solution

  • There is no webpart .cs files in Visual Web Part created in VS 2012. You can add Web Part properties to ascx.cs files e.g.

         [WebBrowsable(true),
         WebDisplayName("Page Title"),
         WebDescription("Title displayed on the page"),
         Category("Test Properties"),
         Personalizable(PersonalizationScope.Shared)]
        public string PageTitle
        {
            get
            {
                return _pageTitle;
            }
            set
            {
                _pageTitle = value;
            }
        }