I UPDATED the code with code behind. I'm doing something dynamic with the label contrtol.
I have the following jQuery code working as it is (passing the value of 'test") but what I want to do is to pass the value of the label control (lblNames). I'm using the label control to collect the uploaded file names. Is there a way?
jQuery:
$(document).ready(function () {
$("#btnUpload").click(function () {
$("#Notes", top.document).val('test');
});
});
ASPX code:
<asp:Label ID="lblNames" runat="server" visible="true" ></asp:Label>
Code Behind:
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
Dim fileExt As String
fileExt = System.IO.Path.GetExtension(FileUpload1.FileName)
If (fileExt <> ".exe") Then
Dim fileNames As New List(Of String)
Try
Dim hfc As HttpFileCollection = Request.Files
lblFiles.Text = String.Empty
lblNames.Text = String.Empty
For i As Integer = 0 To hfc.Count - 1
Dim hpf As HttpPostedFile = hfc(i)
If hpf.ContentLength > 0 Then
fileNames.Add(hpf.FileName)
hpf.SaveAs(Server.MapPath("/directory") & "\" & System.IO.Path.GetFileName(hpf.FileName))
lblFiles.Text += "<b>File: </b>" & hpf.FileName & " " & " Uploaded Successfully! <br />"
lblNames.Text += hpf.FileName & ", "
Else
lblWarning.Text = "Please choose a file to upload."
End If
Next i
Catch ex As Exception
End Try