Description
The Microsoft.SharePoint.WebControls.ContentDatabaseSection class inherits System.Web.UI.UserControl and provides methods and properties to build the required UI components for the initial setup of a Web application’s content database. These components are:
1) InputFormSection control that contains this control.
2) InputFormRadioButton controls (i.e. RadWindowsAuth ) to specify whether Sql or Window authentication must be used.
3) A drop down list (DdlSearchServer) that specifies Search Service instance.
4) InputFormSection that contains Search Service instance drop down list.
5) Several TextBox controls (i.e. TxtDatabaseAccount ) to collect data such as database server name, password, user name and etc.
6) Several required field validation controls (i.e. ReqValDatabaseAccount ) to validate the data of child input controls.
7) Several labels to provide description to child input controls.
This control exposes a public property called DisplayMode (of type ContentDatabaseSectionMode Enumeration), which puts the control in different display modes. For example, in Default mode, all of child controls are enabled, where as in other two modes (Disabled and AuthenticationEdit), some or all of controls are disabled.
This control is mostly used in custom Web parts or Web part pages targeted at Central administration Web application or any other sites meant to be used for administrative purposes. End users typically don’t need to interact with Web application content databases.
The Usage Scenario
To customize your forms to contain content database section, you can follow two approaches:
1) You can extend ContentDatabaseSection classto define your own custom control that deals with the content databases of your Web application. You can create a class library that inherits ContentDatabaseSection class, implement your custom logic and copy the DLL of your project to the global assembly cache (GAC). You also need to add an .ascx file containing your custom control template definition (which references the custom DLL) to <%WSS System Directory%>\TEMPLATE\ADMIN folder.
2) You can reuse out of the box ContentDatabaseSection user control (locatedin <%WSS System Directory%>\TEMPLATE\ADMIN) in your Web parts or Web part pages. This can be done either declaratively or using a programmatic approach by loading it dynamically and add it to the control collection of either your Web part or Web part page. Below is one example of loading the user control programmatically in CreateChildControls event of a Web part:
C# Code Example
ContentDatabaseSection cdsCtrl = (ContentDatabaseSection)Page.LoadControl("~/_admin/ContentDatabaseSection.ascx");
cdsCtrl.ID = "CDS";
this.Controls.Add(cdsCtrl);
Visual Basic .NET Code Example
Dim cdsCtrl As ContentDatabaseSection = DirectCast(Page.LoadControl("~/_admin/ContentDatabaseSection.ascx"), ContentDatabaseSection)
cdsCtrl.ID = "CDS"
Me.Controls.Add(cdsCtrl)