Reputation: 1577
I am using the DNN FilePickerUploader control in a settings view of a module.
The image is not a required element.
When the settings form is accessed, the first image in the SiteRoot folder is selected by default. This is a problem if the user opens the settings to modify something else. Since the first image is selected, that image is saved. The user must deselect the image.
I would like the FilePickerUploader to load with no image selected by default. Is this possible?
So far I have tried:
None of these have an effect on the default value seen in the control.
Upvotes: 0
Views: 700
Reputation: 1577
The attribute most important to the default initial value is the "Required" attribute.
By setting "Required" to False, the following tag will cause the control to be populated with the first image in the initial directory (site root by default):
<dnn:FilePickerUploader ID="imagePicker1" runat="server" Required="False" />
By setting "Required" to True, the following tag will cause the control to show the site root as the default folder and will not have an image selected by default:
<dnn:FilePickerUploader ID="imagePicker2" runat="server" Required="True" />
Testing shows that the "Required" attribute does not affect the validity of the page. Page.IsValid will evaluate to True with or without an image selected.
To me this attribute seems counter-intuitive. When I set "Required" to True, I expect that the user will be required to select something. In this case it would be acceptable to include an image by default because they are being forced to select one. The control however only fills in the image by default if "Required" is set to False.
Upvotes: 0
Reputation: 582
I've checked in the portal settings module control.
Try begin with the initialization of the portalid attribute with the current portalid and put String.Empty as the default value for the FilePath attributes. That seems to be sufficient.
Upvotes: 1
Reputation: 8943
You might try using the URL Control, that's what Engage Publish uses for "thumbnail" selection (there's also a custom selector mentioned here that isn't used anymore.
https://github.com/ChrisHammond/Engage-Publish/blob/master/Controls/ThumbnailSelector.ascx
<%@ Register TagPrefix="dnn" TagName="URL" Src="~/controls/URLControl.ascx" %>
<dnn:URL ID="ctlMediaFile" runat="server" Width="325" ShowUrls="true" ShowTabs="False" ShowLog="False" ShowTrack="False" Required="False"/>
This allows you to use the folder/file selection in DNN, or allows the user to enter a URL to an external Image as well if they want.
Upvotes: 1