Knowledge Base
Hiding A File Upload Control If A File Has Been Uploaded
Last Post 29 Jan 2010 10:06 AM by DNNDev Admin. 0 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
DNNDev AdminUser is Offline
Posts:5800
Avatar

--
29 Jan 2010 10:06 AM  
XMod Pro provides a file upload control that enables your users to upload files to your website. When saving the record, the file's name is stored in your database. When editing the record, the file's name is displayed and a link to upload a file is displayed next to it.

We received a request from a customer who wanted to be able to hide that Upload link when editing a record if a file had been previously uploaded. This is easily accomplished using jQuery in your EditForm:

In this example, I've given an ID of "fuFile" to the FileUpload control. You'll need to modify it to meet your control's ID.

<ScriptBlock BlockType="StartupScript" ScriptId="HideFileUpload" RegisterOnce="True">
<script type="text/javascript">
var $lnk = jQuery('#' + FeedbackForm.fuFile + '__lnkNewFile');
var $txt = jQuery('#' + FeedbackForm.fuFile + '__txtFileName');
($txt.val()) ? $lnk.hide() : $lnk.show();
</script>
</ScriptBlock>

This is using jQuery but can be modified to work without it.

What I'm doing is registering this script to appear near the bottom of the page, so it runs after the controls in the form have been created. It is assigning a variable to the "Upload File" link of the control as well as a hidden text box that is used to store the file's name. It then either hides or shows the link based on whether there is a value in the textbox.

Power Your Website With XMod Pro
Buy XMod Pro Today
You are not authorized to post a reply.

Active Forums 4.1
spacer
dummy