473,386 Members | 1,795 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,386 software developers and data experts.

How to diable the file upload input after

Sorry, I am only a month new to .net world. I have no ideal where this
subject should be posted. so i post her and the .general group. Hope
you do not mind.
I used the example from MS of file upload doc to create an upload vb.net
page. The page includes three file upload inputs. I tried to disable
(make the input field disappear) after the file(s) was successfully
uploaded. If there were two files, then the 2 of three inputs should
disappear. If there is one, then one input should be disabled. I tried
to run a JavaScript function to do that, but failed. Nothing happen. I
also tried to write out a JavaScript function that did not work either.
Can any one help me? I only learn vb.net about a month. I tried to
use my ASP and JavaScript knowledge; apparently there are lots different.

here are part of the codes. In .aspx javascript section I have such
function disableInput(n)
{
vav j = 0 ;
for( var i =0; i< document.form1.elements.length; i++){
if( document.form1.elements[i].type =='file') {
document.form1.elements[i].style.visibility = 'hidden';
if ( (j + 1) == n )
return true;
}
}
}

In my .aspx.vb file
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If (Not IsPostBack) Then
...
Else
..
Button1.Attributes.Add("OnClick", "alert('The selected
file(s) has been loaded.\nThe Order will be refreshed to reveal the
file(s).');refreshOrder('" & [cart_id]() & "');self.close();")
End If
....
End Sub
Sub SubmitButton_Click(ByVal Source As Object, ByVal e As EventArgs)
Dim filepath As String =
ConfigurationSettings.AppSettings("FileStorage")
Dim MAXSIZE As Integer =
ConfigurationSettings.AppSettings("MAXSIZE")
Dim uploadedFiles As HttpFileCollection = Request.Files
Dim strFilenamesCollection As String = ""
Dim i As Integer = 0

Dim arrPostedFile As New ArrayList
Dim fullFileName As String
Span1.InnerHtml = Nothing

If totalUpload(uploadedFiles) Then
Do Until i = uploadedFiles.Count
Dim userPostedFile As HttpPostedFile = uploadedFiles(i)

Try
If (userPostedFile.ContentLength > 0) Then
....
userPostedFile.SaveAs(filepath & "\" & cart_id
& "~" & _
Path.GetFileName(userPostedFile.FileName))

.....
fullFileName = cart_id & "~" &
Path.GetFileName(userPostedFile.FileName)
arrPostedFile.Add(fullFileName)

End If

Catch ex As Exception
Span1.InnerHtml += "Error:<br>" & ex.Message
End Try
i += 1
Loop
Span1.InnerHtml += "Above file(s) has been saved.<br>"
....
Else
Span1.InnerHtml = "<font color=red><b>Total file uploaded
has exceeded " & MAXSIZE / 1000000 & " MB.</b></font>"
End If

End Sub
Private Sub disablePostedFileInout(ByVal n As Integer)
Dim jScript As String

jScript = "<script language='javascript'>"
' jScript = jScript & "function disableInput(" & n & " ) { "
jScript = jScript & " var j = 0; "
jScript = jScript & " for( var i =0; i<
document.form1.elements.length; i++){"
jScript = jScript & " if( document.form1.elements[i].type
=='file') { "
jScript = jScript & "
document.form1.elements[i].style.visibility = 'hidden'; "
jScript = jScript & " if ( (j + 1) == " & n & " ) return; "
jScript = jScript & " } ) "
jScript = jScript & "</script>"
RegisterStartupScript("DisableInput", jScript.ToString)

My question is how to call a javascript without using any control, such
as button.

C Chang
Jul 21 '05 #1
0 945

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

Similar topics

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...
6
by: tshad | last post by:
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...
0
by: cschang | last post by:
Sorry, I am only a month new to .net world. I have no ideal where this subject should be posted. so i post her and the .general group. Hope you do not mind. I used the example from MS of file...
6
by: Vic Spainhower | last post by:
Hello, I am trying to do a FTP file upload which works fine on my localhost but on my ISP server it fails. I can't seem to find where I can go to find the specific cause of the failure. In both...
7
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file"...
2
chunk1978
by: chunk1978 | last post by:
hi there... i've written a small PHP script to upload files onto my server... but whenever i upload a file, the file size becomes automatically smaller on the server... for example: i uploaded a...
1
by: chrisj | last post by:
I'm using freeASPupload and got some assistance integrating to a Member script. It works successfully. In this modified version there are two groups that use this upload script. Members of one...
4
cassbiz
by: cassbiz | last post by:
Could use some help here. This script is carrying over an image just fine but the text isn't coming over. can you see why it is not working???? from the form I want to carry over two lines of...
6
Jacotheron
by: Jacotheron | last post by:
I need a PHP script that can upload music files (mp3). The script is for a home project I have started a while ago. I have a MySQL database of all the music that I have. Other computers on the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...

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.