Uploading files

Docs

Binary data can be treated in one of two ways in the form control. If it is an image then it can be previewed directly in the browser by setting the column Image property to true or if the binary data should be downloaded in the case of files such as spreadsheets or PDF's then you can set the column File method. In this sample the ImageConfiguration class is used to automatically associate uploaded file meta-data with columns in the form and the OnFileSelected event is used to set the description column of the record based on the name of the uploaded file.

Preview binary data


Download binary data

Razor
                                
                                        
DbNetEditCore imagesEdit = new DbNetEditCore("dbnetsuitecore", "images", "imageForm");
imagesEdit.Insert = true;
imagesEdit.Delete = true;
imagesEdit.Column("Content").Image(new ImageConfiguration(new List() { "jpg", "png" }, new Dictionary() { { FileMetaData.FileName, "FileName" }, { FileMetaData.ContentType, "ContentType" }, { FileMetaData.LastModified, "LastModified" }, { FileMetaData.Size, "Size" } }));
imagesEdit.Bind(EventType.OnFileSelected, "setDescription");
@imagesEdit.Render()

DbNetEditCore filesEdit = new DbNetEditCore("dbnetsuitecore", "files", "fileForm");
filesEdit.Insert = true;
filesEdit.Delete = true;
filesEdit.Column("Content").File(new FileConfiguration("pdf", new Dictionary() { { FileMetaData.FileName, "FileName" }, { FileMetaData.ContentType, "ContentType" }, { FileMetaData.LastModified, "LastModified" }, { FileMetaData.Size, "Size" } }));
filesEdit.Bind(EventType.OnFileSelected, "setDescription");
@filesEdit.Render()