Hi i want to implement async Fileupload in asp.net with jquery.
When i will upload that time i have to submit others textbox vaue also.
So to do that i am using the logic ...
first i will upload the file and it will save to server then in final submit button i will send the form data and uploaded file name with service.
Frist of all i dnt want to refresh my page so i want to use Ajax tookit async fileupload control.
After file upload i want to get file name as response so that in final submit button i can send the form data and file name as well.
I have written code but im facing problem.
whever response im getting i am writting that in a label and that label value i want in backend .
but that labe value is empty always i dnt know why it is....
Here is the code..........................
- <script type="text/javascript">
- function uploadComplete(sender, args) {
- $get("<%=Label1.ClientID%>").innerHTML = args.get_fileName();
- }
- </script>
aspx code
- <form id="form1" runat="server">
- <asp:ScriptManager ID="ScriptManager1" runat="server">
- </asp:ScriptManager>
- <h3>File upload control</h3>
- <div>
- <table border="1" cellpadding="1" cellspacing="0">
- <tr>
- <td>
- Name :
- </td>
- <td>
- <input type="text" id="name" />
- </td>
- </tr>
- <tr>
- <td>
- Photo :
- </td>
- <td>
- <ajaxToolkit:AsyncFileUpload ID="AsyncFileUpload1" runat="server" OnClientUploadComplete="uploadComplete"
- OnUploadedComplete="AsyncFileUpload1_UploadedComplete" UploaderStyle="Modern" />
- </td>
- </tr>
- </table>
- <br />
- <asp:Label ID="Label1" runat="server"></asp:Label>
- </div>
- <div>
- <asp:Button Text="Save" ID="btnSave" runat="server" OnClick="btnSave_Click" />
- <asp:Button Text="Cancel" ID="btnCancel" runat="server" OnClick="btnCancel_Click" />
- </div>
- </form>
C# code
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
- {
- AsyncFileUpload1.SaveAs(Server.MapPath("~/Temp/") + Path.GetFileName(AsyncFileUpload1.FileName));
- }
- protected void btnSave_Click(object sender, EventArgs e)
- {
- }
- protected void btnCancel_Click(object sender, EventArgs e)
- {
- string file = Label1.Text;
- }
Problem 1:
I want to get file name in btnCancel_Click but now it coming empty.
here i will delete the file if user cancle the form.
Problem 2:
If i click to btnCancel_Click then after complete this form again control coming to AsyncFileUpload1_UploadedComplete this function. (C#)
i don't want that.
Problem 3:
I want to use generic handler how to use that?
Someone help me please! if you dnt understand the you can ask me again.
Last 3 days im stuck in file upload control.
Remember it is not MVC application it is asp.net application.
I want to implement async file uploader.
I dnt want to use extra button to save a file.
Its a single file uploader control.
I dnt to do maximum this in client side and upload and file save should handle by handler.
I serch lot i did not get actual solution.
If you have any other idea then you are welcome.
Thank you in advance.