Jun 23, 2016, 1:41 PM
FileUpload fails when its id is not defined
When FileUpload's id is defined (line 22) it's possible to upload files multiple times
On the following sample, select a file then press Upload button
It outputs:
It outputs:
On the following sample, select a file then press Upload button
It outputs:
It outputs:
Thanks in advance.
On the following sample, select a file then press Upload button
It outputs:
File Count: 1
File Name: C:\Files\aaaa.pdf
Once upload is complete select another file, then press Upload button againIt outputs:
File Count: 1
File Name: C:\Files\bbbb.pdf
<!DOCTYPE html>
<html>
<head runat="server">
<script type="text/javascript">
var Upload = function () {
var form = App._frm;
if (form.isValid()) {
form.getForm().submit({
clientValidation: true,
waitMsg: Ext.view.AbstractView.prototype.loadingText,
url: Ext.net.ResourceMgr.resolveUrl("~/Example/Save")
});
}
}
</script>
</head>
<body>
<ext:ResourceManager ScriptMode="Debug" Theme="Crisp" runat="server" />
<ext:FormPanel ID="_frm" Title="Ext.NET" BodyPadding="5" Layout="AnchorLayout" DefaultAnchor="100%" Width="350" Height="150" runat="server">
<FieldDefaults LabelAlign="Top" MsgTarget="Side" />
<Items>
<ext:FileUploadField ID="_fuf" ValidateOnBlur="false" ValidateOnChange="false" EmptyText="Select a File" Icon="Magnifier" ButtonText="" AllowBlank="false" runat="server" />
</Items>
<Buttons>
<ext:Button Flat="true" Icon="DiskUpload" Text="Upload" OnClientClick="Upload()" runat="server" />
</Buttons>
</ext:FormPanel>
</body>
</html>
namespace SandBox.Controllers
{
public class ExampleController : System.Web.Mvc.Controller
{
public ActionResult Index() => View();
public FormPanelResult Save()
{
Debug.WriteLine($"File Count: {Request.Files.Count}");
if (Request.Files.Count > 0)
{
Debug.WriteLine($"File Name: {Request.Files.Get(0).FileName}");
}
return new FormPanelResult { IsUpload = true, Success = true };
}
}
}
But when FileUpload's id IS NOT defined (line 22), only the first upload works as expected.On the following sample, select a file then press Upload button
It outputs:
File Count: 1
File Name: C:\Files\aaaa.pdf
Once upload is complete select another file, then press Upload button againIt outputs:
File Count: 0
<!DOCTYPE html>
<html>
<head runat="server">
<script type="text/javascript">
var Upload = function () {
var form = App._frm;
if (form.isValid()) {
form.getForm().submit({
clientValidation: true,
waitMsg: Ext.view.AbstractView.prototype.loadingText,
url: Ext.net.ResourceMgr.resolveUrl("~/Example/Save")
});
}
}
</script>
</head>
<body>
<ext:ResourceManager ScriptMode="Debug" Theme="Crisp" runat="server" />
<ext:FormPanel ID="_frm" Title="Ext.NET" BodyPadding="5" Layout="AnchorLayout" DefaultAnchor="100%" Width="350" Height="150" runat="server">
<FieldDefaults LabelAlign="Top" MsgTarget="Side" />
<Items>
<ext:FileUploadField ValidateOnBlur="false" ValidateOnChange="false" EmptyText="Select a File" Icon="Magnifier" ButtonText="" AllowBlank="false" runat="server" />
</Items>
<Buttons>
<ext:Button Flat="true" Icon="DiskUpload" Text="Upload" OnClientClick="Upload()" runat="server" />
</Buttons>
</ext:FormPanel>
</body>
</html>
Any ideas to overcome the issue presented above?Thanks in advance.
Last edited by RaphaelSaldanha; Jun 23, 2016 at 1:44 PM.