Hi Salim,
As I have told you, by design it is not possible to rename a file client side, you should do a postback. Also, according our support policy we answer only for our controls (and not for ASP.NET upload control), I have showed you how to implement this solution in both MVC Project and ASP web site, so my suggestion is either to consider to change your approach or to use UpdatePanel for example and then the postback that is performed wont bother you.
Hi Zdravko,
I don't want any postback. Otherwise, I would have used the normal ASP.NET upload control. I have noticed onething. I added a handler and set the property of the igUpload uploadUrl to this handler, and when clicking on upload, it is going to this handler. The question is, what should I write in this handler?
Thanks
Hello Salim,
You can use the same code in order to do in in ASP project. The difference here is that you need again to call the server, although you will not have the event arguments like FileName, Path etc. and we will need to get them differently. I have created a new sample for you that is using igUpload in ASP.NET web site and again if the Image already exists in the upload folder, will be renamed.
There are a few things that you should know, there is a button which will perform the postback to the server, and I simulate a click on FileUploading. Also I use hidden filed in order to get the uploaded file name.
Code snippet:
..................................
................................
Looking forward to hearing from you.
Thanks Zdravko, but I am not using MVC. I am simply using the control in an ASP.NET. How to do the same thing in ASP.NET?
I have created a sample for you in order to show you how to rename the file when it is uploaded, although the approach is not implemented client side. You will need to handle in your controller igUpload_FinishingUpload and in there to rename the file if already exists in this folder. In order to do this I use simple recursion, as you can see from the sample every file that you upload (and exists in the folder) will be renamed with numeric counter. Please have a loo at the sample and let me know if this approach suits your needs.
By design our igUpload will always override the uploaded file if already exists.