Re: Uploading file input clearing on postback



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" <tscheiderich@xxxxxxxxxxxxxxx> wrote in message
news:OZ8O1TVxFHA.1284@xxxxxxxxxxxxxxxxxxxxxxx
> "Peter Rilling" <peter@xxxxxxxxxxxxxxxxxx> wrote in message
> news:%23nft5uUxFHA.2076@xxxxxxxxxxxxxxxxxxxxxxx
>>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(HttpApplication app) +340
> NFission.WebControls.ScrollKeeperModule.context_BeginRequest(Object
> sender, EventArgs e) +33
>
> System.Web.SyncEventExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
> +60
> System.Web.HttpApplication.ExecuteStep(IExecutionStep 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" <tscheiderich@xxxxxxxxxxxxxxx> wrote in message
>> news:OfR0TRUxFHA.2652@xxxxxxxxxxxxxxxxxxxxxxx
>>>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
>>>
>>
>>
>
>


.


Loading