Example 1: Adding FileVistaControl via tagPrefix
Example 2: Adding FileVistaControl programmatically
Example 3: Advanced features; events, user logic and subfolder permissions


This example demonstrates adding FileVistaControl to the page programmatically in the codebehind:



Here is the code which renders the control above in the codebehind:

protected void Page_Load(object sender, EventArgs e)

{

    FileVistaControl fileVistaControl = (FileVistaControl)LoadControl("~/FileVistaControl/filevista.ascx");

 

    fileVistaControl.Style = "width: 800px; height: 600px";

    fileVistaControl.Language = "en";

    fileVistaControl.LicenseKey = "";

 

    //New property "FileListColumns" in v1.9 for accessing the columns of the file list.

    //Currently only the size (number of characters) of the columns can be overridden.

    //0 = Name, 1 = Size , 2 = Type, 3 = Date Modified

    //For instance, the Name column size can be set to 30 characters like this:

    fileVistaControl.FileListColumns[0].Size = 30;

 

    //Create a root folder and add it to the control

    FileVistaRootFolder rootFolder1 = new FileVistaRootFolder("Root Folder 1", @"C:\TestFolder\filevistacontrol\RootFolder1");

    rootFolder1.Permissions = FileVistaPermissions.Full;

    fileVistaControl.RootFolders.Add(rootFolder1);

 

    //Create another root folder and add it to the control

    FileVistaRootFolder rootFolder2 = new FileVistaRootFolder("Root Folder 2", @"C:\TestFolder\filevistacontrol\RootFolder2");

    rootFolder2.Permissions = FileVistaPermissions.Traverse | FileVistaPermissions.List

                                | FileVistaPermissions.Download | FileVistaPermissions.Upload;

    rootFolder2.Quota = "2000 KB";

    rootFolder2.AllowedFileTypes = "*.jpg; *.gif";

    fileVistaControl.RootFolders.Add(rootFolder2);

 

    //Render the control in the placeholder.

    PlaceHolder1.Controls.Add(fileVistaControl);

}



Descriptions for the code: