By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,644 Members | 2,439 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,644 IT Pros & Developers. It's quick & easy.

Uploading file input clearing on postback

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
"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

P: n/a
"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

P: n/a
"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 discussion thread is closed

Replies have been disabled for this discussion.