Aug 04, 2011, 11:17 PM
Fileuploadfield in one click - htmlfile access is denied error
Hello - I am relatively new to EXT.NET. I want to have only one image button. By clicking that user should first be prompted to select file. Once done, the file should get posted to server. I have reused most code from examples on ext.net.
This compiles well but gives error "htmlfile: access is denied at runtime." Can some one help resolve? (Many buttons below are hidden)
(Further trial/error reveals that Its the FileUploadField1.fileInput.dom.click() which is causing problem. If I make fileuploadfield visible and use browse button to select file, it works smooth. But If I use the image button, it causes access problem later when file is posted")
This compiles well but gives error "htmlfile: access is denied at runtime." Can some one help resolve? (Many buttons below are hidden)
(Further trial/error reveals that Its the FileUploadField1.fileInput.dom.click() which is causing problem. If I make fileuploadfield visible and use browse button to select file, it works smooth. But If I use the image button, it causes access problem later when file is posted")
<ext:FileUploadField hidden="true" ID="FileUploadField1" runat="server" ButtonOnly="true" />
<ext:ImageButton ID="SaveButton" runat="server" ImageUrl="./Images/Upload.jpg" >
<Listeners>
<Click Handler="FileUploadField1.fileInput.dom.click();#{HiddButt}.fireEvent('click');" />
</Listeners>
</ext:ImageButton>
<ext:Button ID="HiddButt" runat="server" hidden="true">
<DirectEvents>
<Click
OnEvent="UploadClick"
Before="if (!#{BasicForm}.getForm().isValid()) { return false; }
Ext.Msg.wait('Uploading your photo...', 'Uploading');"
Failure="Ext.Msg.show({
title : 'Error',
msg : 'Error during uploading',
minWidth: 200,
modal : true,
icon : Ext.Msg.ERROR,
buttons : Ext.Msg.OK
});">
</Click>
</DirectEvents>
</ext:Button>
Here is the vb script for server side<script runat="server">
Protected Sub UploadClick(sender As Object, e As DirectEventArgs)
Dim tpl As String = "Uploaded file: {0}<br/>Size: {1} bytes"
If Me.FileUploadField1.HasFile Then
ImageButton1_Click(sender)
Ext.Net.X.Msg.Show(New MessageBoxConfig() With { _
.Buttons = MessageBox.Button.OK, _
.Icon = MessageBox.Icon.INFO, _
.Title = "Success", _
.Message = String.Format(tpl, Me.FileUploadField1.PostedFile.FileName, Me.FileUploadField1.PostedFile.ContentLength) _
})
Else
Ext.Net.X.Msg.Show(New MessageBoxConfig() With { _
.Buttons = MessageBox.Button.OK, _
.Icon = MessageBox.Icon.[ERROR], _
.Title = "Fail", _
.Message = "No file uploaded" _
})
End If
End Sub
Last edited by Daniil; Aug 08, 2011 at 6:03 PM.
Reason: Please use [CODE] tags