SharePoint WebControls
In this post I’m going to tell you how to use SharePoint’s web controls in our custom code. It is very easy to use and it gives look and feel of SharePoint’s default forms. First we have to add the reference for Microsoft.SharePoint assembly and add using Microsoft.SharePoint.WebControls Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll) Namespace: Microsoft.SharePoint.WebControls SPWeb web = SPContext.Current.Web ; SPList list = web.Lists[ "ListName" ]; // Display Lookup field with Multiple selection enabled MultipleLookupField mlkpfield = new MultipleLookupField (); mlkpfield.ListId = list.ID; mlkpfield.FieldName = "MultiLookup" ; mlkpfield.ControlMode = SPControlMode .New; this .Controls.Add(mlkpfield); // Display List View Toolbar ViewToolBar toolbar = new ViewToolBar (); SPContext context = SPContext .GetContext( this .Context, list.DefaultView.ID, list.ID, SPContext .Current.Web); toolbar.RenderContext = con...