Sitefinity CMS

Uploading User Control to Toolbox Send comments on this topic.
See Also
Developing with Sitefinity > Controls > Adding New Controls to Sitefinity > User Controls > Uploading User Control to Toolbox

Glossary Item Box

In order to be able to add the user control in the Edit page mode through the administrative part of Sitefinity, the user control has to be uploaded to the Add Controls section. Following are instructions on how to do that: 

  1. Start the Sitefinity Administer Site application and log on to your account.
  2. Open the site where you want to use the new control.
  3. Select the Pages link on the Dashboard.
  4. Open any page (or create a new page if there are no pages in the site) and click Edit Page.
  5. Click the Upload Control link.
  6. In the Upload control dialog box, set the Name to Upload control. (See Figure 1)
  7. Set the Group to User controls
  8. Use the Select button to browse to the ascx file you created. When prompted to add the code-behind file, select OK. This will display a second select box. Use the Select button to browse to the ascx.cs file.
  9. Click Upload to upload the control.
  10. Click I'm done.
  11. Close Sitefinity.

    User Controls - Uploading using Sitefinity UI 

    Figure 1

 

Adding the User Control through the web.config File

Another option to add a user control to the toolbox is to add it to the web.config file. 

This subsection is alternative to the preceding one: a user control could either be added to the web.config file or be uploaded after clicking the Upload Control link placed on the toolbox.

Following are instructions on how to do that: 

  1. Open the web.config file of the current project.
  2. Add the following code to the <toolboxControls> tag:
    web.config Copy Code
    <toolboxControls>
     
    ...
     
    <add
        
    name="User_Control_Name"
        
    section="Toolbox_Section"
        
    type="User_Control_Namespace, User_Control_Assembly"
        
    description="Some description"
    />

        where each string should be substituted for the values for the given control.

 

Placing the User Control on a Page

The user control has to be added to the page in order to use its functionality. Following are the instructions how to do that: 

  1. Start the Sitefinity Administration Site application and log on to your account.
  2. Select the Pages link on the Dashboard.
  3. Open any page and click Edit Page.
  4. Drag the UploadControl from the list of controls to any content placeholder on the page.  (See Figure 2)

     Page Edit mode

    Figure 2

  1. Click the Edit link above the UserControl on the page.
  2. Set the ID property for the control to Upload1.  (See Figure 3)
  3. Set the TargetFolder property for the control to ~/MyControls.

     

    Figure 3

  1. Click I'm Done.
  2. Click Save Changes.

 

Publishing and Viewing the Page

The Edit mode of the page allows adding, editing or removing controls. In order to view the resulting page, do the following: 

  1. Click Publish.
  2. Click Live Site.
  3. Use the site navigation controls to open the page where you placed the User Control. You should be able to see the RadUpload and button controls.

 

See Also