ASP.NET Interfaces: Internet File Select and Upload Dialog

xiaoxiao2021-03-06  68

Download Demo Project - 0.8 KB Internet File Select and Upload Dialog (Latest Version)

Introduction

Uploading files to the Internet has become much easier since we have ASP.NET, but to build a solution for upload, browse, preview ... is not quite as easy as it is in the Windows Forms world (e.g., ShellDialog).

That Can do all these things for you: Internet file select and upload dialog.

THE Control

First, we need to register the assembly:

<% @ Page language = "c #"%>

<% @ Register tagprefix = "ctrl"

Namespace = "staticdust.web.ui.controls"

askMBLY = "staticdust.web.ui.controls.uploaddialog"%>

Our Next Step is to insert a TextBox to Store The name of the selfip file:

and the "UploadDialogButton" that is associated to the TextBox by its "ControlToFill" property. We also need to define the "UploadDirectory". "images /" will be translated to the root of your application.

ID = "MyuploadDialogbutton"

ControlTofill = "MyImage"

UploadDirectory = "images /"

Runat = "server"

/>

The "UploadDialogButton" renders to a button (or a link, if you define the "Text" property) with JavaScript code to open a file called "UploadDialog.aspx". This is where we need to configure the HttpHandler.

The httphandler

To configure a httphandler, We need to add it to the web.config file (a Configuration File for A ASP.NET Web, Found In The Root of the Application):

...

...

PATH = "UploadDialog.aspx"

VERB = "*"

TYPE = "staticdust.web.uploadhandler, staticdust.web.ui.controls.uploaddialog"

VALIDATE = "false"

/>

Now, we are ready to use the uploaddialog.

More

There Are A Few Properties of The "UploadDialogbutton" To Configure the Dialog:

AllowCreateFolder: Displays a button in the dialog to create a subfolder in the UploadDirectory AllowDelete:. Displays a button in the dialog to delete files CssClass:.. Adds the given CSS class to the button DemoMode: Disables upload, delete, and subfolder creation. FileNameOnly: If set to true, only the filename (without path) will be returned FileTypes:. Define what files can be uploaded / are displayed (eg, "jpg, gif, png") MaxBytes:. Define a maximum file size for the upload MaxHeight:. Define a maximum height for the upload / browsing (jpg, gif and png only) MinHeight:. Define a minimum height for the upload / browsing (jpg, gif and png only) TotalHeight:. Define a total height for the upload / browsing (jpg, gif and png only) MaxWidth:. Define a maximum width for the upload / browsing (jpg, gif and png only) MinWidth:. Define a minimum width for the upload / browsing (jpg, gif and png only ). TotalWidth: Define a total width for the upload / browsing (jpg, gif and png only). NOUPLOAD: DISABLES the upload function ShowUploadFirst:. Opens the dialog with the upload function Text:. Define something else than the button E.g., a text or an image that will be surrounded by an A-tag with the needed JavaScript code..

About Daniel Fisher (Lennybacon)

转载请注明原文地址:https://www.9cbs.com/read-122561.html

New Post(0)