ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Pass (Send) TextBox value to Generic Handler using jQuery Ajax in ASP.Net<p>Hi <a class="username" rel="nauna"> nauna</a>,</p> <p>For sending textbox value to handler use query string parameter to send.</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">HTML</span></strong></p> <pre class="brush: html">&lt;input type=&#34;file&#34; name=&#34;postedFile&#34; /&gt; &lt;input type=&#34;button&#34; id=&#34;btnUpload&#34; value=&#34;Upload&#34; /&gt; &lt;asp:TextBox ID=&#34;TextBox1&#34; runat=&#34;server&#34;&gt;&lt;/asp:TextBox&gt; &lt;progress id=&#34;fileProgress&#34; style=&#34;display: none&#34;&gt;&lt;/progress&gt; &lt;hr /&gt; &lt;span id=&#34;lblMessage&#34; style=&#34;color: Green&#34;&gt;&lt;/span&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;jquery-1.8.3.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; $(&#34;body&#34;).on(&#34;click&#34;, &#34;#btnUpload&#34;, function () { $.ajax({ url: &#39;&lt;%= ResolveUrl(&#34;~/HandlerCS.ashx&#34;)%&gt;&#39; + &#34;?Name=&#34; + $(&#39;#TextBox1&#39;).val(), type: &#39;POST&#39;, data: new FormData($(&#39;form&#39;)[0]), cache: false, contentType: false, processData: false, success: function (file) { $(&#34;#fileProgress&#34;).hide(); $(&#34;#lblMessage&#34;).html(&#34;&lt;b&gt;&#34; + file.name + &#34;&lt;/b&gt; has been uploaded.&#34;); }, xhr: function () { var fileXhr = $.ajaxSettings.xhr(); if (fileXhr.upload) { $(&#34;progress&#34;).show(); fileXhr.upload.addEventListener(&#34;progress&#34;, function (e) { if (e.lengthComputable) { $(&#34;#fileProgress&#34;).attr({ value: e.loaded, max: e.total }); } }, false); } return fileXhr; } }); }); &lt;/script&gt;</pre> <p><strong><span style="text-decoration: underline;">Handler</span></strong></p> <p><strong>C#</strong></p> <pre class="brush: csharp">&lt;%@ WebHandler Language=&#34;C#&#34; Class=&#34;HandlerCS&#34; %&gt; using System; using System.IO; using System.Net; using System.Web; using System.Web.Script.Serialization; public class HandlerCS : IHttpHandler { public void ProcessRequest(HttpContext context) { //Check if Request is to Upload the File. if (context.Request.Files.Count &gt; 0) { //Fetch TextBox Value from QueryString. string name = context.Request.QueryString[&#34;Name&#34;]; //Fetch the Uploaded File. HttpPostedFile postedFile = context.Request.Files[0]; //Set the Folder Path. string folderPath = context.Server.MapPath(&#34;~/Uploads/&#34;); //Set the File Name. string fileName = Path.GetFileName(postedFile.FileName); //Save the File in Folder. postedFile.SaveAs(folderPath + fileName); //Send File details in a JSON Response. string json = new JavaScriptSerializer().Serialize(new { name = fileName }); context.Response.StatusCode = (int)HttpStatusCode.OK; context.Response.ContentType = &#34;text/json&#34;; context.Response.Write(json); context.Response.End(); } } public bool IsReusable { get { return false; } } }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">&lt;%@ WebHandler Language=&#34;VB&#34; Class=&#34;HandlerVB&#34; %&gt; Imports System Imports System.IO Imports System.Net Imports System.Web Imports System.Web.Script.Serialization Public Class HandlerVB : Implements IHttpHandler Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest &#39;Check if Request is to Upload the File. If context.Request.Files.Count &gt; 0 Then &#39;Fetch TextBox Value from QueryString. Dim name As String = context.Request.QueryString(&#34;Name&#34;) &#39;Fetch the Uploaded File. Dim postedFile As HttpPostedFile = context.Request.Files(0) &#39;Set the Folder Path. Dim folderPath As String = context.Server.MapPath(&#34;~/Uploads/&#34;) &#39;Set the File Name. Dim fileName As String = Path.GetFileName(postedFile.FileName) &#39;Save the File in Folder. postedFile.SaveAs(folderPath + fileName) &#39;Send File details in a JSON Response. Dim json As String = New JavaScriptSerializer().Serialize(New With { .name = fileName }) context.Response.StatusCode = CInt(HttpStatusCode.OK) context.Response.ContentType = &#34;text/json&#34; context.Response.Write(json) context.Response.End() End If End Sub Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Get Return False End Get End Property End Class</pre>https://www.aspforums.net:443/Threads/189409/Pass-Send-TextBox-value-to-Generic-Handler-using-jQuery-Ajax-in-ASPNet/https://www.aspforums.net:443/Threads/189409/Pass-Send-TextBox-value-to-Generic-Handler-using-jQuery-Ajax-in-ASPNet/Fri, 06 Sep 2019 03:55:53 GMT