Thursday, 4 March 2010

Visual Web Part in SharePoint 2010

Visual Web Part in SharePoint 2010

Before I explain what it is, I will remind what we were doing to have visual control in SharePoint 2007. We were creating our ascx controls in TEMPLATE\CONTROLTEMPLATES folder. To be able to use the control in our webpart, we were loading it in CreateChildControls method with this.Page.LoadControl(_ascxPath); . _ascxPath is path for our control. You can see the following complete syntax.

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

So what is new now. To be honest nothing has changed in strategy. But Visual studio made a great job including this future into Visual Studio. We do not need to think about deployment hassle and all other painfull operations. Now we can just simply add and change this future quickly.

Here is the sample about How to create Visual Web Part in Visual Studio 2010.
http://www.helloitsliam.com/archive/2009/10/20/sharepoint-2010-%E2%80%93-create-a-visual-web-part.aspx

1 comment:

  1. Nice post. Thanks for explaining the visual web part. I am currently studying about SharePoint in detail and this article has helped me a lot. Also thanks for sharing the complete syntax.
    sharepoint electronic signature

    ReplyDelete