Adding Additional File Inputs to C1Upload
You can confirm whether or not to add a new file to C1Upload’s file input row by using the handler name of the OnClientAdding event to let the user know if they still want to add a new file input. To add client-side script to C1Upload’s OnClientAdding event, complete the following:
1. Add C1Upload to your page and click on its smart tag to open its Tasks menu.
2. Select the Register in Web.config item from the smart tag.
3. Click the drop-down arrow next to OnClientAdding and select Add new client side event handler to create a place holder for the new event handler in your source file.
<script type="text/javascript" id="ComponentOneClientScript1">
function C1Upload1_OnClientAdding(){
//
// Put your code here.
//
};
4. The client-side handler, OnClientAdding requires two parameters: the ID that identifies the sender C1Upload and an eventArgs that contains the data of the event. Add the following script to the OnClientAdding() so it appears like the following:
<script type="text/javascript" id="ComponentOneClientScript1">
function C1Upload1_OnClientAdding(upload, e){
{
if (upload.getFiles().length >= upload.get_fileCount())
e.set_cancel(!confirm("Do you want to add a new file input?"));
}
};
</script>
The preceding scripts uses C1Upload’s client-side getFiles() method to check to see if the amount of files are larger than the number of files to be uploaded. If they are then a window is displayed asking you if you want to add a new file input.
Once you select OK, the name of the file is added to the C1Upload’s file input row.
|