Using FileUpload in DNN Setting.ascx is possible?

first time asking a question here.

I create a DNN module and in the setup .. When I try to add any form of FileUpload there. I managed to add ASP FileUpload, as well as Telerik RadUpload, but when I click the button, I added to save and check the downloaded file, which is empty and no longer contains any data. I thought it was encoded incorrectly at first, but after adding to View.ascx it works fine. Of course, not where I want.

I believe the problem may be how Setting.ascx works in DNN. I believe that he uses the AJAX form to display it so that it interferes. It's hard to say though. While I'm in, can anyone confirm that the Setting.ascx parameter uses AJAX, and these button presses cause asynchronous callbacks? Thanks.

+4
source share
3 answers

You are right in thinking that the form uses AJAX (previously through the UpdatePanel , now through the RadAjaxPanel in DNN 6.x), and what prevents the download. In most scenarios, you simply switch to a regular callback by calling ScriptManager.RegisterPostBackControl , but in the case of settings, you donโ€™t have a direct link to LinkButton that saves the settings.

You will probably need to add your own button to the upload form after the user has selected the file. DNN own UrlControl uses a system where there is a Download button next to the Browse button. DNN also has a newer DnnFilePicker control, which can also encapsulate what you want. You just need to add the @ Register directive to use them. For instance:

 <%@ Reference tagPrefix="dnn" tagName="UrlControl" Src="~/controls/URLControl.ascx" %> <%@ Reference tagPrefix="dnn" Assembly="DotNetNuke.Web" Namespace="DotNetNuke.Web.UI.WebControls" %> <dnn:UrlControl runat="server" ID="FileUpload" ShowLog="false" ShowNewWindow="false" ShowTrack="false" ShowImages="false" ShowNone="false" ShowTabs="false" ShowUrls="false" ShowUsers="false" ShowFiles="false" ShowUpLoad="true" /> <dnn:DnnFilePicker runat="server" ID="FilePicker" FileFilter="jpg,png,gif" /> 
+3
source

Man, just don't put the updated panel outside your ascx control. If you need to use updatepanel, put it in ascx. This will solve your problem!

0
source

I was able to solve this problem by following these steps:

  • Create my own submit button, and donโ€™t rely on the Save button built into the page
  • Adding the following LoadSettings() method:

    ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(cmdUpload);

Where cmdUpload is the identifier of my submit button.

You will need to add a link to System.Web and System.Web.Extensions to compile.

0
source

Source: https://habr.com/ru/post/1402532/


All Articles