473,411 Members | 2,080 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,411 software developers and data experts.

Uploading file input clearing on postback

I have an upload file input as:
<input id="MyFile" style="width:300px" type="File" runat="Server">

This works fine, but I find that if my page doesn't pass validation during
postback, the page comes back with all the data intact, except for the
upload object. The text box for "MyFile" (my example) is always cleared.

Why is that and is there a way to stop that from happening?

Thanks,

Tom
Nov 19 '05 #1
6 4110
I don't think the browser will let you set the value for that field. What
you might want to do is to cache the file during the first submit. Keep in
mind that the file is always uploaded, even if validation fails, so it might
improve response time after the first failure if the user does not have to
upload the file again.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:Of**************@TK2MSFTNGP14.phx.gbl...
I have an upload file input as:
<input id="MyFile" style="width:300px" type="File" runat="Server">

This works fine, but I find that if my page doesn't pass validation during
postback, the page comes back with all the data intact, except for the
upload object. The text box for "MyFile" (my example) is always cleared.

Why is that and is there a way to stop that from happening?

Thanks,

Tom

Nov 19 '05 #2
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I don't think the browser will let you set the value for that field. What
you might want to do is to cache the file during the first submit. Keep in
mind that the file is always uploaded, even if validation fails, so it
might improve response time after the first failure if the user does not
have to upload the file again.
That may answer another question that has been driving me crazy today.

I need to check to see if the file size is too large.

The problem is I can't seem to stop it from trying to load the file and then
giving me an error page

************************************************** *********************************
Maximum request length exceeded.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Maximum request length
exceeded.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:
[HttpException (0x80004005): Maximum request length exceeded.]
System.Web.HttpRequest.GetEntireRawContent() +895
System.Web.HttpRequest.GetMultipartContent() +58
System.Web.HttpRequest.FillInFormCollection() +255
System.Web.HttpRequest.get_Form() +50
NFission.WebControls.Config.EnablePage(HttpApplica tion app) +340
NFission.WebControls.ScrollKeeperModule.context_Be ginRequest(Object
sender, EventArgs e) +33
System.Web.SyncEventExecutionStep.System.Web.HttpA pplication+IExecutionStep.Execute()
+60
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously) +87
************************************************** ************************************************** *****************

I can't seem to stop it. There doesn't seem to be anywhere to put my
try/catch block. I tried putting it around my upload routing that I call
when I do my submit. That is the point at which I look for the size of the
file.

But that doesn't seem to matter.

I have literally ripped out that code (and any that refers to my upload
objects ID).

<input id="MyFile" style="width:300px" type="File" runat="Server">

and now my submit buttons event does nothing:

Sub SaveChanges_Click(s as Object, e as ImageClickEventArgs)
End Sub

And it still tries to load the file when I hit the submit button.

Why and how can I test for the size of the file to give the user a warning
that the file is too large?

Thanks,

Tom
"tshad" <ts**********@ftsolutions.com> wrote in message
news:Of**************@TK2MSFTNGP14.phx.gbl...
I have an upload file input as:
<input id="MyFile" style="width:300px" type="File" runat="Server">

This works fine, but I find that if my page doesn't pass validation
during postback, the page comes back with all the data intact, except for
the upload object. The text box for "MyFile" (my example) is always
cleared.

Why is that and is there a way to stop that from happening?

Thanks,

Tom


Nov 19 '05 #3
Well, you cannot check the size because your code does not get invoked until
the entire file is downloaded. You can increase the max size by changing
the maxRequestLength attribute in the machine.config.

One thing I have never done, but you can try, is to see if the error event
in the global.asax can trap that error.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:OZ**************@tk2msftngp13.phx.gbl...
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I don't think the browser will let you set the value for that field. What
you might want to do is to cache the file during the first submit. Keep
in mind that the file is always uploaded, even if validation fails, so it
might improve response time after the first failure if the user does not
have to upload the file again.


That may answer another question that has been driving me crazy today.

I need to check to see if the file size is too large.

The problem is I can't seem to stop it from trying to load the file and
then giving me an error page

************************************************** *********************************
Maximum request length exceeded.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Maximum request length
exceeded.

Source Error:

An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:
[HttpException (0x80004005): Maximum request length exceeded.]
System.Web.HttpRequest.GetEntireRawContent() +895
System.Web.HttpRequest.GetMultipartContent() +58
System.Web.HttpRequest.FillInFormCollection() +255
System.Web.HttpRequest.get_Form() +50
NFission.WebControls.Config.EnablePage(HttpApplica tion app) +340
NFission.WebControls.ScrollKeeperModule.context_Be ginRequest(Object
sender, EventArgs e) +33

System.Web.SyncEventExecutionStep.System.Web.HttpA pplication+IExecutionStep.Execute()
+60
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously) +87
************************************************** ************************************************** *****************

I can't seem to stop it. There doesn't seem to be anywhere to put my
try/catch block. I tried putting it around my upload routing that I call
when I do my submit. That is the point at which I look for the size of
the file.

But that doesn't seem to matter.

I have literally ripped out that code (and any that refers to my upload
objects ID).

<input id="MyFile" style="width:300px" type="File" runat="Server">

and now my submit buttons event does nothing:

Sub SaveChanges_Click(s as Object, e as ImageClickEventArgs)
End Sub

And it still tries to load the file when I hit the submit button.

Why and how can I test for the size of the file to give the user a warning
that the file is too large?

Thanks,

Tom

"tshad" <ts**********@ftsolutions.com> wrote in message
news:Of**************@TK2MSFTNGP14.phx.gbl...
I have an upload file input as:
<input id="MyFile" style="width:300px" type="File" runat="Server">

This works fine, but I find that if my page doesn't pass validation
during postback, the page comes back with all the data intact, except
for the upload object. The text box for "MyFile" (my example) is always
cleared.

Why is that and is there a way to stop that from happening?

Thanks,

Tom



Nov 19 '05 #4
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:uO**************@TK2MSFTNGP15.phx.gbl...
Well, you cannot check the size because your code does not get invoked
until the entire file is downloaded. You can increase the max size by
changing the maxRequestLength attribute in the machine.config.

One thing I have never done, but you can try, is to see if the error event
in the global.asax can trap that error.
I'll try that, but I know that there is nowhere (that I can find) to
surround some code with a try/catch block to catch the error.

As a matter of fact, the error seems to be coming from somewhere else than
the normal error page you get.

Normally, if I have my trace on, I can still the traces below with my
objects and trace statements. Not so with this error page. You get the
error page only and non of your trace statements, so you can't even tell how
far you've gotten.

This can be a real problem if the downloading of the file is done while the
other code is being processed.

My question would be, does it happen before the Page_Load function?

If not, you could be in the middle of processing your page and you get this
random error page that stops the processing. The problem is you don't know
where you got to.

Thanks,

Tom
"tshad" <ts**********@ftsolutions.com> wrote in message
news:OZ**************@tk2msftngp13.phx.gbl...
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I don't think the browser will let you set the value for that field.
What you might want to do is to cache the file during the first submit.
Keep in mind that the file is always uploaded, even if validation fails,
so it might improve response time after the first failure if the user
does not have to upload the file again.


That may answer another question that has been driving me crazy today.

I need to check to see if the file size is too large.

The problem is I can't seem to stop it from trying to load the file and
then giving me an error page

************************************************** *********************************
Maximum request length exceeded.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Maximum request length
exceeded.

Source Error:

An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:
[HttpException (0x80004005): Maximum request length exceeded.]
System.Web.HttpRequest.GetEntireRawContent() +895
System.Web.HttpRequest.GetMultipartContent() +58
System.Web.HttpRequest.FillInFormCollection() +255
System.Web.HttpRequest.get_Form() +50
NFission.WebControls.Config.EnablePage(HttpApplica tion app) +340
NFission.WebControls.ScrollKeeperModule.context_Be ginRequest(Object
sender, EventArgs e) +33

System.Web.SyncEventExecutionStep.System.Web.HttpA pplication+IExecutionStep.Execute()
+60
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously) +87
************************************************** ************************************************** *****************

I can't seem to stop it. There doesn't seem to be anywhere to put my
try/catch block. I tried putting it around my upload routing that I call
when I do my submit. That is the point at which I look for the size of
the file.

But that doesn't seem to matter.

I have literally ripped out that code (and any that refers to my upload
objects ID).

<input id="MyFile" style="width:300px" type="File" runat="Server">

and now my submit buttons event does nothing:

Sub SaveChanges_Click(s as Object, e as ImageClickEventArgs)
End Sub

And it still tries to load the file when I hit the submit button.

Why and how can I test for the size of the file to give the user a
warning that the file is too large?

Thanks,

Tom

"tshad" <ts**********@ftsolutions.com> wrote in message
news:Of**************@TK2MSFTNGP14.phx.gbl...
I have an upload file input as:
<input id="MyFile" style="width:300px" type="File" runat="Server">

This works fine, but I find that if my page doesn't pass validation
during postback, the page comes back with all the data intact, except
for the upload object. The text box for "MyFile" (my example) is
always cleared.

Why is that and is there a way to stop that from happening?

Thanks,

Tom



Nov 19 '05 #5
"tshad" <ts**********@ftsolutions.com> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:uO**************@TK2MSFTNGP15.phx.gbl...
Well, you cannot check the size because your code does not get invoked
until the entire file is downloaded. You can increase the max size by
changing the maxRequestLength attribute in the machine.config.

One thing I have never done, but you can try, is to see if the error
event in the global.asax can trap that error.
I'll try that, but I know that there is nowhere (that I can find) to
surround some code with a try/catch block to catch the error.

As a matter of fact, the error seems to be coming from somewhere else than
the normal error page you get.

Normally, if I have my trace on, I can still the traces below with my
objects and trace statements. Not so with this error page. You get the
error page only and non of your trace statements, so you can't even tell
how far you've gotten.

This can be a real problem if the downloading of the file is done while
the other code is being processed.

My question would be, does it happen before the Page_Load function?

If not, you could be in the middle of processing your page and you get
this random error page that stops the processing. The problem is you
don't know where you got to.


Another problem here is that I would want to capture the error so that I can
put a message on the screen telling the user that his file was too big.
This would allow him to upload a different file, without losing all the
input he has already put in. If I go to an error page, all that data is
lost.

Tom
Thanks,

Tom

"tshad" <ts**********@ftsolutions.com> wrote in message
news:OZ**************@tk2msftngp13.phx.gbl...
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I don't think the browser will let you set the value for that field.
What you might want to do is to cache the file during the first submit.
Keep in mind that the file is always uploaded, even if validation fails,
so it might improve response time after the first failure if the user
does not have to upload the file again.

That may answer another question that has been driving me crazy today.

I need to check to see if the file size is too large.

The problem is I can't seem to stop it from trying to load the file and
then giving me an error page

************************************************** *********************************
Maximum request length exceeded.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Maximum request length
exceeded.

Source Error:

An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:
[HttpException (0x80004005): Maximum request length exceeded.]
System.Web.HttpRequest.GetEntireRawContent() +895
System.Web.HttpRequest.GetMultipartContent() +58
System.Web.HttpRequest.FillInFormCollection() +255
System.Web.HttpRequest.get_Form() +50
NFission.WebControls.Config.EnablePage(HttpApplica tion app) +340
NFission.WebControls.ScrollKeeperModule.context_Be ginRequest(Object
sender, EventArgs e) +33

System.Web.SyncEventExecutionStep.System.Web.HttpA pplication+IExecutionStep.Execute()
+60
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously) +87
************************************************** ************************************************** *****************

I can't seem to stop it. There doesn't seem to be anywhere to put my
try/catch block. I tried putting it around my upload routing that I
call when I do my submit. That is the point at which I look for the
size of the file.

But that doesn't seem to matter.

I have literally ripped out that code (and any that refers to my upload
objects ID).

<input id="MyFile" style="width:300px" type="File" runat="Server">

and now my submit buttons event does nothing:

Sub SaveChanges_Click(s as Object, e as ImageClickEventArgs)
End Sub

And it still tries to load the file when I hit the submit button.

Why and how can I test for the size of the file to give the user a
warning that the file is too large?

Thanks,

Tom

"tshad" <ts**********@ftsolutions.com> wrote in message
news:Of**************@TK2MSFTNGP14.phx.gbl...
>I have an upload file input as:
> <input id="MyFile" style="width:300px" type="File" runat="Server">
>
> This works fine, but I find that if my page doesn't pass validation
> during postback, the page comes back with all the data intact, except
> for the upload object. The text box for "MyFile" (my example) is
> always cleared.
>
> Why is that and is there a way to stop that from happening?
>
> Thanks,
>
> Tom
>



Nov 19 '05 #6
"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
"tshad" <ts**********@ftsolutions.com> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:uO**************@TK2MSFTNGP15.phx.gbl...
Well, you cannot check the size because your code does not get invoked
until the entire file is downloaded. You can increase the max size by
changing the maxRequestLength attribute in the machine.config.

One thing I have never done, but you can try, is to see if the error
event in the global.asax can trap that error.

I tried that and it works.

I'll try that, but I know that there is nowhere (that I can find) to
surround some code with a try/catch block to catch the error.

As a matter of fact, the error seems to be coming from somewhere else
than the normal error page you get.

Normally, if I have my trace on, I can still the traces below with my
objects and trace statements. Not so with this error page. You get the
error page only and non of your trace statements, so you can't even tell
how far you've gotten.

This can be a real problem if the downloading of the file is done while
the other code is being processed.

My question would be, does it happen before the Page_Load function?

If not, you could be in the middle of processing your page and you get
this random error page that stops the processing. The problem is you
don't know where you got to.
Another problem here is that I would want to capture the error so that I
can put a message on the screen telling the user that his file was too
big. This would allow him to upload a different file, without losing all
the input he has already put in. If I go to an error page, all that data
is lost.


This one is a real problem

The problem is that the user may not realize that the field has been cleared
out after he gets a validation error on one of the other fields and then
think that the file was upload, when in fact it wasn't.

Tom
Tom

Thanks,

Tom

"tshad" <ts**********@ftsolutions.com> wrote in message
news:OZ**************@tk2msftngp13.phx.gbl...
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
>I don't think the browser will let you set the value for that field.
>What you might want to do is to cache the file during the first submit.
>Keep in mind that the file is always uploaded, even if validation
>fails, so it might improve response time after the first failure if the
>user does not have to upload the file again.

That may answer another question that has been driving me crazy today.

I need to check to see if the file size is too large.

The problem is I can't seem to stop it from trying to load the file and
then giving me an error page

************************************************** *********************************
Maximum request length exceeded.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Maximum request length
exceeded.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

Stack Trace:
[HttpException (0x80004005): Maximum request length exceeded.]
System.Web.HttpRequest.GetEntireRawContent() +895
System.Web.HttpRequest.GetMultipartContent() +58
System.Web.HttpRequest.FillInFormCollection() +255
System.Web.HttpRequest.get_Form() +50
NFission.WebControls.Config.EnablePage(HttpApplica tion app) +340
NFission.WebControls.ScrollKeeperModule.context_Be ginRequest(Object
sender, EventArgs e) +33

System.Web.SyncEventExecutionStep.System.Web.HttpA pplication+IExecutionStep.Execute()
+60
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously) +87
************************************************** ************************************************** *****************

I can't seem to stop it. There doesn't seem to be anywhere to put my
try/catch block. I tried putting it around my upload routing that I
call when I do my submit. That is the point at which I look for the
size of the file.

But that doesn't seem to matter.

I have literally ripped out that code (and any that refers to my upload
objects ID).

<input id="MyFile" style="width:300px" type="File" runat="Server">

and now my submit buttons event does nothing:

Sub SaveChanges_Click(s as Object, e as ImageClickEventArgs)
End Sub

And it still tries to load the file when I hit the submit button.

Why and how can I test for the size of the file to give the user a
warning that the file is too large?

Thanks,

Tom
>
> "tshad" <ts**********@ftsolutions.com> wrote in message
> news:Of**************@TK2MSFTNGP14.phx.gbl...
>>I have an upload file input as:
>> <input id="MyFile" style="width:300px" type="File" runat="Server">
>>
>> This works fine, but I find that if my page doesn't pass validation
>> during postback, the page comes back with all the data intact, except
>> for the upload object. The text box for "MyFile" (my example) is
>> always cleared.
>>
>> Why is that and is there a way to stop that from happening?
>>
>> Thanks,
>>
>> Tom
>>
>
>



Nov 19 '05 #7

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

Similar topics

4
by: dickiedyce | last post by:
Hi there. I've spent the weekend getting ever more frustrated, trying to get an upload file function working on a website. The site is hosted by a company called oneandone. They're using PHP...
5
by: Ron Brennan | last post by:
Good afternoon. The entire task that I'm trying to achieve is to allow a user to browse and upload multiple files simultaneously, hiding the Browse button of <input> tags of type="file" and...
3
by: Er bengaor | last post by:
Hi. I am trying to simulate the fileupload html control in order to use different css styles in the editbox and button. To do this, I'm using a hidden fileupload control and javascript. But when...
0
by: Dom | last post by:
Hi I want to allow users upload a variable number of files from a single page. User nominates the number of files and then is presented with a corresponding number of input boxes. I create...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
4
by: Mark Miller | last post by:
I've been trying to execute a javascript function just before submit on a form that contains an <input type="file"> input field and it isn't working. The reason I want to do this is the end users...
5
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or...
1
by: Ram | last post by:
hi, i'm trying to upload files. i used <input type=file id=Uploadfile runat=server">. i have placed the control in Updatepanel(AJAX) when i'm trying to upload it.. it is showing Object...
3
ganesanji
by: ganesanji | last post by:
hi all, I have written a php coding for uploading a file to a specific folder or location in server which is a Linux server. I think the coding for file uploaing is correct. But it does not...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.