Drupal 9 webform issue with file element - drupal

I have a problem with which I have been struggling for several days. So i have an webform with a file element inside and on submit button the page is refreshing instead of submitting the form. If i remove the file element the form work corectly.
Someone have the same problem?

Related

How to correctly load webform using ajax in Drupal 8?

The page I need to make is a bit complex and my team and I face many problems with it.
We need to have a page with multiples sections (just square blocs with text on it). Each section displays (on click) a select. When we click on that select, we have to load a webform using AJAX and here is our problem.
We created a view with a select exposed filter and when we change the select value, a webform is loaded. BUT only the HTML is here, the input masks on the fields are not loaded until we click again on the apply button for loading another webform (or the same as the first one, doesn't matter).
So, how can we correctly load our webform ?
And, even if the masks are loaded on the second load, we don't have our custom handler called when we submit the form. Instead, we are redirect to htp://ourwebsite.com/views/ajax and the custom handler is never called.
Thank you for your time ! :)

ASP.NET two forms

I have been trying to integrate the jquery file upload component into my project. Currently it works fine when there is only that component on the page.
The component uses the form tag as the drag and drop area on the page. This is an issue since there can be only one form tag in an asp.net web form page. In addition, the form tag defines the action that uploads the file.
This is how the form code looks like:
<form id="fileupload" action="api/FileHandler" method="POST" enctype="multipart/form-data">
I want this component to be in the middle of the page. How do I go about doing this?
Thanks.
EDIT: This is the file upload component!
I am using this example!
As the link that #MikeSmithDev suggested I changed the form tag into a div tag and that fixed it. It seems having a form and an action where not being used as a form. The JQuery code did the setup of the drag and drop area, setup the event, and raised the event based on the tag with the specified ID. So the form tag was not really necessary.

Make one popup which can be used on multiple pages in ASP.Net

I have two web-form pages in ASP, one for viewing a record and and another for editing it. I would like to have a link on each which popups a box to allow editing a certain property on the record. If I only placed it on the Edit page, I would use an UpdatePanel but I would have to copy and paste code if I wanted it on the View page as well. Is there a way to have the code in one area which be can be referenced and used from both pages?
Edit: I know I could make a custom control to handle it although it would include all its HTML on the page when the page first loads, not when the link is clicked.
Edit2: I wanted to avoid having the contents of the popup rendered when the page first loads but now I realize it's just a matter of not binding any data in it until the Postback occurs.
You can use a MasterPage for both the pages, and put the popup with UpdatePanel on the master page, so you can access it from both the pages.
Hope it helps.
Don't forget to upvote it if it solves you problem.
Thanks.. :)
Make the bulk of the panel a user control (ascx). Then just put a thin wrapper around it on both the pages where you need it. The bulk of the code is then in the ascx and ascx.vb and does not need to be written twice.

asp.net mvc Upload File ajax

Hi ive got an mvc form with a fileupload functionality. Ive got an action that accepts an file and extracts thumbnails from it, after which the user can select the images and then proceed to submit the form. How can post the initial file via ajax, bearing in mind, this is not the final submission on the form and I want to retain user input. ie no postback
Thanks
I use the ajaxupload plugin for jQuery. Lots of sample code is provided on the site. From the site:
[The] plugin creates invisible file input on top of the button you provide, so when user clicks on your button the normal file selection window is shown. And after user selects a file, plugin submits form that contains file input to an iframe. So it isn’t true ajax upload, but brings same user experience.
Browsers don't allow the uploading of files via ajax. There are several good workarounds, however.

ASP.Net file upload with an empty posted files collection

I have an ASP.NET file upload control which sits as part of a form. The file upload control is on the content page while the form definition is on a master page across the site. I've added multipart/form-enc to the form on the master page.
I'm using jQuery to submit the form as I show a dialog box from jQuery UI.
When I post, no file is returned to the server. The file upload control has no file and HttpFileCollection is empty. How can I find the posted file?
Most dialogs take your content, wrap it, and place the result just before </body> in the page...this is a problem in ASP.Net because that's outside the <form></form>, it needs to be inside to be included in the POSTed data.
When you create the dialog, make it append inside the <form> when it finishes instead of the <body>, for example this is what you'd do with the jQuery UI dialog:
$("#myDiv").dialog({ ...options... }).parent().appendTo("form:first");
Now that it's been moved inside the <form>, it should post correctly.

Resources