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.Call code behind method on Ajax FileUpload Complete in ASP.Net<p>Hi <a class="username" rel="nauna">nauna</a>,</p> <p>You have to use <span style="text-decoration: underline;">OnClientUploadComplete</span> event to define a javascript function to call the Code Behind function.</p> <p>For calling code behind method refer below article.</p> <p><a href="https://www.aspsnippets.com/Articles/Call-Code-Behind-function-from-Client-Side-JavaScript-in-ASPNet.aspx" target="_blank">Call Code Behind function from Client Side (JavaScript) in ASP.Net</a></p> <p>Refer the below example.</p> <p><strong><span style="text-decoration: underline;">HTML</span></strong></p> <pre class="brush: html">&lt;asp:ToolkitScriptManager runat=&#34;server&#34; EnablePageMethods=&#34;true&#34;&gt; &lt;/asp:ToolkitScriptManager&gt; &lt;asp:AjaxFileUpload ID=&#34;AjaxFileUpload11&#34; runat=&#34;server&#34; MaximumNumberOfFiles=&#34;5&#34; Width=&#34;400px&#34; OnUploadComplete=&#34;OnUploadComplete&#34; OnClientUploadComplete=&#34;uploadComplete&#34; /&gt; &lt;br /&gt; &lt;asp:Label ID=&#34;lblMesg&#34; runat=&#34;server&#34; /&gt; &lt;script type=&#34;text/javascript&#34;&gt; function uploadComplete(sender) { PageMethods.GetCurrentTime(OnSuccess); } function OnSuccess(response, userContext, methodName) { $get(&#34;&lt;%=lblMesg.ClientID%&gt;&#34;).innerHTML = response; } &lt;/script&gt;</pre> <p><strong><span style="text-decoration: underline;">C#</span></strong></p> <pre class="brush: csharp">protected void OnUploadComplete(object sender, AjaxFileUploadEventArgs e) { string fileName = Path.GetFileName(e.FileName); string filePath = &#34;~/Uploads/&#34; + fileName; AjaxFileUpload11.SaveAs(Server.MapPath(&#34;~/Uploads/&#34; + fileName)); } [System.Web.Services.WebMethod] public static string GetCurrentTime() { return &#34;The Current Time is: &#34; + DateTime.Now.ToString(); }</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><img src="https://i.imgur.com/G4bjcvm.gif" alt="" /></p>https://www.aspforums.net:443/Threads/633401/Call-code-behind-method-on-Ajax-FileUpload-Complete-in-ASPNet/https://www.aspforums.net:443/Threads/633401/Call-code-behind-method-on-Ajax-FileUpload-Complete-in-ASPNet/Wed, 01 Aug 2018 04:07:05 GMT