Click here to Skip to main content
15,893,663 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi I'm very sorry if my english is so bad just neglict it anyway
I have a web app which have a textbox and a button, that download excelfiles

what I did is I create a class that will handle in downloading the excel files

this is the function that download my excel files from the webserver
VB
HttpContext.Current.Response.ContentType = "Application/xmsexcel"
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" & textbox1.text &".xls")            HttpContext.Current.Response.TransmitFile(Server.MapPath("~\Bin\toExcel.xls"))



my question is how can I reset the textbox value on my asp.net after I've downloaded the excel files



I've try Response.redirect but what happen is it didn't download the files, try using a javascript but I still don't get the best solution

hope someone can help me with this :)
Posted
Updated 16-Apr-13 1:17am
v2
Comments
Thanks7872 16-Apr-13 6:20am    
which textbox?how many textbox?what you want to do?
iMaker.ph 16-Apr-13 6:34am    
I want to clear the item of the textbox
FYI textbox1 contains the filename of the excel that I want to download.
Prasad Khandekar 16-Apr-13 6:46am    
Hello,

After clicking the button your server side handler is streaming the excel file and user probably gets a save as dialog and he/she saves the file. What you can do is use either a javascript timer and start it in the client side button handler which will take user to same page again via Location.Replace(URL) method. This way your page gest reloaded without affecting the already started download.

Another way without time could be as simple as setting the target attribute of form to _blank in the clide side download button click handler and use Location.Replace to reload the page. By setting target attribuet on the form you will force the post to open a new window.


Regards,
iMaker.ph 16-Apr-13 7:23am    
isn't there anyway not to refresh the page ? I mean like just getting the elements on my web via vb.net and then change it, I'll try your 1st method anyway :)

Set textbox1.text=string.empty wherever you want to clear the textbox value.
 
Share this answer
 
Comments
iMaker.ph 16-Apr-13 7:16am    
I've tried it but it won't work
Thanks7872 16-Apr-13 7:39am    
suppose you have called function for excel on click event of the button.add textbox1.text=string.empty right below the function call thats it.if you still have any issues post the code here in which you are calling the function.i have tested and its working.
iMaker.ph 16-Apr-13 8:01am    
yes your correct on my button click event I just call my class function that's all..
Thanks7872 16-Apr-13 8:06am    
then write this line below the call to that function thats it....if this solves your issue,you can accept the above answer and rate it.
iMaker.ph 16-Apr-13 22:54pm    
this isn't working :(
I think the only way to reset a textbox is to use a javascript
JavaScript
document.getElementById("<%= TextBox1.ClientID %>").value = "";
 
Share this answer
 
Comments

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900