Previous Thread:   how is this normally done?

9/30/2005 3:26:59 PM    Re: Two Questions
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



9/30/2005 3:40:02 PM    Re: Two Questions
Agree; client-side is the way to go here to hide/unhide the controls.  
  
<neilmcguigan@gmail.com> wrote in message  
  
news:1128119219.839352.290640@o13g2000cwo.googlegroups.com...

9/30/2005 4:12:00 PM    Two Questions
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

10/3/2005 10:13:23 AM    Re: Two Questions
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" <riley_wright@hotmail.com> wrote in message  
  
news:Oenc8vgxFHA.3756@tk2msftngp13.phx.gbl...

10/5/2005 12:09:28 PM    Re: Two Questions
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.