473,320 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

What is probably a simple question about a file control

Ed
I'm rather new to ASP .Net, so I appologize in advance if I'm asking a dumb
question here. I've been searching all over the place for an answer and
haven't found a single one.

I'm working on a form that gives the user a file control to upload a file
from their machine to my server. With this file control are two buttons; one
marked "Upload", the other marked "Cancel". The cancel button is to give
them the option of just backing out entirely. Upon clicking the Cancel
button, the C# code redirects them to the previous page.

The problem I'm having is that if the user has already selected a file on
their computer (through clicking Browse, etc.) and they click "Cancel" the
file is uploaded to the server anyway. How do I prevent the upload if they
click the "Cancel" button and not the "Upload" button.

Thanks in advance,
ed
Nov 19 '05 #1
2 1096
if the only functionality of cancel is to go back to last page , change
cancel button to an HTML button.. it doesnt need to post back the page.

<input type=button onclick='javascript:history.back(-1);' value='Cancel'>

Still how is it uploading file on cancel button?.. :) Is your c# code to
save the file on in the btnUpload_Click(Sender as Object, e as EventArgs)
[btnUpload being name of your uplaod control] or in the Page_Load ?

btnUpload_Click(Sender as Object, e as EventArgs) is the currect place for
saving the file to server..

"Ed" wrote:
I'm rather new to ASP .Net, so I appologize in advance if I'm asking a dumb
question here. I've been searching all over the place for an answer and
haven't found a single one.

I'm working on a form that gives the user a file control to upload a file
from their machine to my server. With this file control are two buttons; one
marked "Upload", the other marked "Cancel". The cancel button is to give
them the option of just backing out entirely. Upon clicking the Cancel
button, the C# code redirects them to the previous page.

The problem I'm having is that if the user has already selected a file on
their computer (through clicking Browse, etc.) and they click "Cancel" the
file is uploaded to the server anyway. How do I prevent the upload if they
click the "Cancel" button and not the "Upload" button.

Thanks in advance,
ed

Nov 19 '05 #2
Ed
Sreejith,
thanks. Thats exactly what I was looking for.

ed

"Sreejith Ram" wrote:
if the only functionality of cancel is to go back to last page , change
cancel button to an HTML button.. it doesnt need to post back the page.

<input type=button onclick='javascript:history.back(-1);' value='Cancel'>

Still how is it uploading file on cancel button?.. :) Is your c# code to
save the file on in the btnUpload_Click(Sender as Object, e as EventArgs)
[btnUpload being name of your uplaod control] or in the Page_Load ?

btnUpload_Click(Sender as Object, e as EventArgs) is the currect place for
saving the file to server..

"Ed" wrote:
I'm rather new to ASP .Net, so I appologize in advance if I'm asking a dumb
question here. I've been searching all over the place for an answer and
haven't found a single one.

I'm working on a form that gives the user a file control to upload a file
from their machine to my server. With this file control are two buttons; one
marked "Upload", the other marked "Cancel". The cancel button is to give
them the option of just backing out entirely. Upon clicking the Cancel
button, the C# code redirects them to the previous page.

The problem I'm having is that if the user has already selected a file on
their computer (through clicking Browse, etc.) and they click "Cancel" the
file is uploaded to the server anyway. How do I prevent the upload if they
click the "Cancel" button and not the "Upload" button.

Thanks in advance,
ed

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Chris Cioffi | last post by:
I started writing this list because I wanted to have definite points to base a comparison on and as the starting point of writing something myself. After looking around, I think it would be a...
4
by: Avery Warren | last post by:
I am investigating converting a wiki site to plone. I am having a lot of difficulty finding good documentation programmatically accessing the ZODB API. A lot of the user feedback is centered on...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
51
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
8
by: Midnight Java Junkie | last post by:
Dear Colleagues: I feel that the dumbest questions are those that are never asked. I have been given the opportunity to get into .NET. Our organization has a subscription with Microsoft that...
63
by: Jake Barnes | last post by:
In the course of my research I stumbled upon this article by Alex Russel and Tim Scarfe: http://www.developer-x.com/content/innerhtml/default.html The case is made that innerHTML should never...
6
by: JonathanOrlev | last post by:
Hello everyone, I have a newbe question: In Access (2003) VBA, what is the difference between a Module and a Class Module in the VBA development environment? If I remember correctly, new...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.