Using FileUltimate in an ASP.NET MVC project
To use FileUltimate in an ASP.NET MVC Project, do the following in Visual Studio:
Make sure you have added references to FileUltimate assemblies as described here.
Optionally set FileUltimate's global configuration (if overriding a default value is required). For example, you may want to set the license key.
You can specify the configuration in
<appSettings>tag of your Web.config.<appSettings> <!-- Set this property only if you have a valid license key, otherwise do not set it so FileUltimate runs in trial mode. --> <add key="FileUltimate:LicenseKey" value="QQJDJLJP34..." /> </appSettings>As you would notice,
FileUltimate:prefix maps toFileUltimateConfiguration.CurrentandFileUltimateWeb:prefix maps toFileUltimateWebConfiguration.Current.Alternatively you can specify the configuration in code, in
Application_Startmethod of your Global.asax.cs:protected void Application_Start(object sender, EventArgs e) { //Set this property only if you have a valid license key, otherwise do not //set it so FileUltimate runs in trial mode. FileUltimateConfiguration.Current.LicenseKey = "QQJDJLJP34..."; }Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) 'Set this property only if you have a valid license key, otherwise do not 'set it so FileUltimate runs in trial mode. FileUltimateConfiguration.Current.LicenseKey = "QQJDJLJP34..." End SubCreate a new View (eg. Index.cshtml) and insert these lines:
@using GleamTech.AspNet.Mvc @using GleamTech.FileUltimate.AspNet.UI <!DOCTYPE html> @{ var fileManager = new FileManager { Width = 800, Height = 600, Resizable = true }; var rootFolder = new FileManagerRootFolder { Name = "A Root Folder", Location = "~/App_Data/RootFolder1" }; rootFolder.AccessControls.Add(new FileManagerAccessControl { Path = @"\", AllowedPermissions = FileManagerPermissions.Full }); fileManager.RootFolders.Add(rootFolder); } <html> <head> <title>File Manager</title> @this.RenderHead(fileManager) </head> <body> @this.RenderBody(fileManager) </body> </html>@Imports GleamTech.AspNet.Mvc @Imports GleamTech.FileUltimate.AspNet.UI <!DOCTYPE html> @Code Dim fileManager = New FileManager() With { .Width = 800, .Height = 600, .Resizable = True } Dim rootFolder = New FileManagerRootFolder() With { .Name = "A Root Folder", .Location = "~/App_Data/RootFolder1" } rootFolder.AccessControls.Add(New FileManagerAccessControl() With { .Path = "\", .AllowedPermissions = FileManagerPermissions.Full }) fileManager.RootFolders.Add(rootFolder) End Code <html> <head> <title>File Manager</title> @Me.RenderHead(fileManager) </head> <body> @Me.RenderBody(fileManager) </body> </html>This will render a file manager component in the page which displays one root folder named "A Root Folder" which points to "~/App_Data/RootFolder1" with Full permissions.
Tip
Alternatively you can add the namespaces globally in Views/Web.config under
<system.web.webPages.razor>/<pages>/<namespaces>tag to avoid adding namespaces in your pages every time:<system.web.webPages.razor> <pages pageBaseType="System.Web.Mvc.WebViewPage"> <namespaces> <add namespace="GleamTech.AspNet.Mvc" /> <add namespace="GleamTech.FileUltimate.AspNet.UI" /> </namespaces> </pages> </system.web.webPages.razor>If you need a standalone file uploader component, insert these lines instead:
@using GleamTech.AspNet.Mvc @using GleamTech.FileUltimate.AspNet.UI <!DOCTYPE html> @{ var fileUploader = new FileUploader { Width = 600, Height = 300, Resizable = true, UploadLocation = "~/App_Data/Uploads" }; } <html> <head> <title>File Uploader</title> @this.RenderHead(fileUploader) </head> <body> @this.RenderBody(fileUploader) </body> </html>@Imports GleamTech.AspNet.Mvc @Imports GleamTech.FileUltimate.AspNet.UI <!DOCTYPE html> @Code Dim fileUploader = New FileUploader() With { .Width = 600, .Height = 300, .Resizable = True, .UploadLocation = "~/App_Data/Uploads" } End Code <html> <head> <title>File Uploader</title> @Me.RenderHead(fileUploader) </head> <body> @Me.RenderBody(fileUploader) </body> </html>