Now, Lets see how to create custom web parts to a visual web part in SharePoint 2013.
If you used new Visual Web Part Template in Visual Studio 2012 to Create Custom WebParts you have first learn about the basic structure of the Visual Web Part in SharePoint 2013.Creating custom properties in SharePoint 2013 is different from creating a Visual Web Part with custom properties in SharePoint 2010. In SharePoint 2013, there is no separate User Control Class( webpartname.cs ) and only web part class (webpartname.aspx.cs) is available. we can directly write custom properties in User Control Class.
following is the SharePoint 2013 Visual Web Part architecture
Now, follow below steps to create a Visual Webpart with Custom Properties in SharePoint 2013. I will show how to create a drop down menu in this article. similarly, you can also create textbox, boolean value,check box etc.
Refer MSDN for Different Custom Properties.
Add Custom Properties to a Visual Web Part:
Using this property in Code behind:
Build and deploy the solution.
If you used new Visual Web Part Template in Visual Studio 2012 to Create Custom WebParts you have first learn about the basic structure of the Visual Web Part in SharePoint 2013.Creating custom properties in SharePoint 2013 is different from creating a Visual Web Part with custom properties in SharePoint 2010. In SharePoint 2013, there is no separate User Control Class( webpartname.cs ) and only web part class (webpartname.aspx.cs) is available. we can directly write custom properties in User Control Class.
following is the SharePoint 2013 Visual Web Part architecture
Now, follow below steps to create a Visual Webpart with Custom Properties in SharePoint 2013. I will show how to create a drop down menu in this article. similarly, you can also create textbox, boolean value,check box etc.
Refer MSDN for Different Custom Properties.
Add Custom Properties to a Visual Web Part:
- Add a Visual Web Part to your project.
- Create a new property by adding the below code in your user control class(webpartname.aspx.cs).
public enum CustomProp { AllProjectPortals, MyProjectPortals } [WebBrowsable(true), Category("Custom Configurations"), Personalizable(), WebDisplayName("WebPart Properties"), WebDescription("Select a properties to change the WebPart display")] public CustomProp WebPartProperty { get; set; }
Using this property in Code behind:
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { lblProjects.Text = this.WebPartProperty.ToString(); } }
Build and deploy the solution.
- Add the Web Part to a Page and Edit the Web Part to see properties.
- Click OK, You can see your Custom Properties displayed on your page.
Create Visual Web part with Custom Properties in SharePoint 2013
Reviewed by Sudheer Gangumolu
on
January 10, 2015
Rating:
It would be great if you provide JavaScript solution for the same as it's trend of sandbox solution after release of SharePoint2013
ReplyDeleteThanks for taking time to check my site, we are trying to provide you the same in the coming days.
ReplyDeleteYou put a 25K deposit down on each property and a mortgage for the remaining 75K, spending all your 100K across 4 properties not just 1 property this time. deyaar projects
ReplyDeleteThanks for sharing us. palos heights IL Real Estate Agents
ReplyDelete