Two Questions

J

john wright

1. I have three Upload controls on my form. When someone clicks a
checkbox, the upload control becomes visible and the user can click the
upload button and the file uploads great. However, if someone clicks on the
second or thrid checkbox to upload a file and makes these corresponding
controls visible to upload files, the file I have selected in the first box
disappears. I have autopost back = true for the checkbox to fire off the
following event:

Dim intAttachment As Integer

Dim strTemp As String

If chkDescription.Checked = True And InStr(txtProblemDescription.Text, "See
Attachment for Details") = 0 Then

txtProblemDescription.Text &= " --See Attachment for Details"

uplDescription.Visible = True

lblDescriptionUpload.Visible = True

Else

intAttachment = InStr(txtProblemDescription.Text, "--See Attachment for
Details", CompareMethod.Text)

If intAttachment > 0 Then

strTemp = Mid(txtProblemDescription.Text, 1, intAttachment - 1)

txtProblemDescription.Text = strTemp

End If

uplDescription.Visible = False

lblDescriptionUpload.Visible = False

End If



uplDescription if the name of the upload control. I need to retain the file
the user selected between post backs. How do I do this?



2. When someone selects a file for upload some files I get the following
error:

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()
System.Web.HttpRequest.FillInFormCollection() +257
System.Web.HttpRequest.get_Form() +50
System.Web.UI.Page.GetCollectionBasedOnMethod()
System.Web.UI.Page.DeterminePostBackMode()
System.Web.UI.Page.ProcessRequestMain()





--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET
Version:1.1.4322.2032



How do I get past this error? What is the max file size. The file size I
am trying to upload is about 4 meg. Any suggestions would be very much
apprecated.



john
 
N

neilmcguigan

I don't think you can do this. You cannot programatically set the value
of the file name in a file upload control, for security reasons.

You may want to consider unhiding the file upload controls on the
client side, using javascript.

Check out the way gmail does it.

Cheers
 
J

john wright

How would I hide these controls with client side javascript. I know how to
add the javascript code with the attributes function, but what code would I
use to hide and show the controls?

John


john wright said:
1. I have three Upload controls on my form. When someone clicks a
checkbox, the upload control becomes visible and the user can click the
upload button and the file uploads great. However, if someone clicks on
the second or thrid checkbox to upload a file and makes these
corresponding controls visible to upload files, the file I have selected
in the first box disappears. I have autopost back = true for the checkbox
to fire off the following event:

Dim intAttachment As Integer

Dim strTemp As String

If chkDescription.Checked = True And InStr(txtProblemDescription.Text,
"See Attachment for Details") = 0 Then

txtProblemDescription.Text &= " --See Attachment for Details"

uplDescription.Visible = True

lblDescriptionUpload.Visible = True

Else

intAttachment = InStr(txtProblemDescription.Text, "--See Attachment for
Details", CompareMethod.Text)

If intAttachment > 0 Then

strTemp = Mid(txtProblemDescription.Text, 1, intAttachment - 1)

txtProblemDescription.Text = strTemp

End If

uplDescription.Visible = False

lblDescriptionUpload.Visible = False

End If



uplDescription if the name of the upload control. I need to retain the
file the user selected between post backs. How do I do this?



2. When someone selects a file for upload some files I get the following
error:

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()
System.Web.HttpRequest.FillInFormCollection() +257
System.Web.HttpRequest.get_Form() +50
System.Web.UI.Page.GetCollectionBasedOnMethod()
System.Web.UI.Page.DeterminePostBackMode()
System.Web.UI.Page.ProcessRequestMain()





--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.4322.2032;
ASP.NET Version:1.1.4322.2032



How do I get past this error? What is the max file size. The file size I
am trying to upload is about 4 meg. Any suggestions would be very much
apprecated.



john
 
N

neilmcguigan

this is a very simple example on how to do it:

<html>
<head>

<script type="text/javascript">

function displayElement(element)
{
element.style.display = "block";
}

function getElement(id)
{
return document.getElementById(id);
}

</script>

</head>
<body>
<form runat="server">
<a href="#" onclick="displayElement(getElement('file1'));
return false;">Upload a file</a>
<br />
<input id="file1" style="DISPLAY: none" type="file" />
</form>
</body>
</html>

You could either have several hidden file fields, and display them when
you need to, or create them on the fly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top