Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to pass value from asp.net server control using jQuery? 2nd try
    text
    copied!<p>I want to pass the value of the label control (lblNames) via jQuery. The current code is not working. I'm using the label control to collect the uploaded file names in code behind. Is there a way?</p> <pre><code>&lt;%@ Page Language="VB" AutoEventWireup="false" CodeFile="FileUploader.aspx.vb" Inherits="FileUploader" EnableEventValidation="false" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head id="Head1" runat="server"&gt; &lt;base target="_self" /&gt; &lt;title&gt;eReserve: Upload Multiple Files&lt;/title&gt; &lt;script src="js/jquery-1.4.2.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="js/jquery.MultiFile.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="js/thickbox.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server" name="uploader"&gt; &lt;div id="upload"&gt; &lt;b&gt;Click "Browse" or "Choose File" to upload a file. &lt;br /&gt;&lt;br /&gt;(If have additional files to upload, click "Browse" or "Choose File" button again).&lt;/b&gt;&lt;br /&gt;&lt;br /&gt; &lt;asp:FileUpload ID="FileUpload1" runat="server" class="multi" /&gt; &lt;br /&gt; &lt;asp:Button ID="btnUpload" runat="server" Text="Upload All" /&gt; &lt;br /&gt;&lt;br /&gt; &lt;asp:Label ID="lblFiles" runat="server" ForeColor="Green"&gt;&lt;/asp:Label&gt; &lt;br /&gt;&lt;br /&gt; &lt;asp:Label ID="lblWarning" runat="server" ForeColor="Red"&gt;&lt;/asp:Label&gt; &lt;br /&gt;&lt;br /&gt; &lt;asp:Label ID="lblCloseWindow" runat="server" ForeColor="Red"&gt;&lt;/asp:Label&gt; &lt;br /&gt;&lt;br /&gt; &lt;asp:Label ID="lblNames" runat="server" class="uploadedNames" visible="true" &gt;&lt;/asp:Label&gt; &lt;input type="submit" id="closeWindow" value="Close Window" onclick="self.parent.tb_remove(); " /&gt; &lt;/div&gt; &lt;/form&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { $("#btnUpload").click(function () { var lblNamesValue = $("#lblNames").val(); $("#Notes", top.document).val(lblNamesValue); }); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>Code behind:</strong></p> <pre><code>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 &lt;&gt; ".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 &gt; 0 Then fileNames.Add(hpf.FileName) hpf.SaveAs(Server.MapPath("/directory") &amp; "\" &amp; System.IO.Path.GetFileName(hpf.FileName)) lblFiles.Text += "&lt;b&gt;File: &lt;/b&gt;" &amp; hpf.FileName &amp; " " &amp; " Uploaded Successfully! &lt;br /&gt;" lblNames.Text += hpf.FileName &amp; ", " Else lblWarning.Text = "Please choose a file to upload." End If Next i Catch ex As Exception End Try </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload