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.[Solved] Bootstrap DataTable row Button Click not working in Mobile View in ASP.Net<p>Hi <a class="username" rel="jovceka"> jovceka</a>,</p> <p>Refer below sample.</p> <p>You need to check width of windows and according to that have to find tr and td.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&gt; &lt;head runat=&#34;server&#34;&gt; &lt;title&gt;&lt;/title&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js&#34;&gt;&lt;/script&gt; &lt;script src=&#34;https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js&#34; type=&#34;text/javascript&#34;&gt;&lt;/script&gt; &lt;script src=&#34;https://cdn.datatables.net/1.10.13/js/dataTables.bootstrap.min.js&#34; type=&#34;text/javascript&#34;&gt;&lt;/script&gt; &lt;script src=&#34;https://cdn.datatables.net/responsive/2.1.1/js/dataTables.responsive.min.js&#34; type=&#34;text/javascript&#34;&gt;&lt;/script&gt; &lt;link rel=&#34;stylesheet&#34; type=&#34;text/css&#34; href=&#34;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css&#34; /&gt; &lt;link rel=&#34;stylesheet&#34; type=&#34;text/css&#34; href=&#34;https://cdn.datatables.net/1.10.13/css/dataTables.bootstrap.min.css&#34; /&gt; &lt;link rel=&#34;stylesheet&#34; type=&#34;text/css&#34; href=&#34;https://cdn.datatables.net/responsive/2.1.1/css/responsive.bootstrap.min.css&#34; /&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://cdnjs.cloudflare.com/ajax/libs/jquery-browser/0.1.0/jquery.browser.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; $(document).ready(function () { $.ajax({ url: &#39;&lt;%= Page.ResolveUrl(&#34;~/WebService.asmx/GetFiles&#34;)%&gt;&#39;, method: &#39;post&#39;, dataType: &#39;json&#39;, success: function (data) { $(&#39;#datatable&#39;).dataTable({ &#34;processing&#34;: true, &#34;paging&#34;: true, &#34;searching&#34;: { &#34;regex&#34;: true }, &#34;responsive&#34;: true, data: data, columns: [ { &#39;data&#39;: &#39;Id&#39; }, { &#39;data&#39;: &#39;Name&#39; }, { &#39;data&#39;: &#39;Data&#39;, &#39;render&#39;: function (Data) { if (!Data) { return &#39;N/A&#39;; } else { var img = &#39;data:image/png;base64,&#39; + Data; return &#39;&lt;img src=&#34;&#39; + img + &#39;&#34; height=&#34;50px&#34; width=&#34;50px&#34; /&gt;&#39;; } } }, { &#34;data&#34;: null, &#34;defaultContent&#34;: &#39;&lt;input type=&#34;button&#34; id=&#34;btnEdit&#34; class=&#34;btn btn-primary&#34; value=&#34;Edit&#34; /&gt;&#39; } ] }); }, error: function (response) { alert(response.responseText); } }); $(&#39;body&#39;).on(&#39;click&#39;, &#39;[id*=btnEdit]&#39;, function () { var data; if ($(window).width() &gt; 320) { data = $(this).parents(&#39;tr&#39;).find(&#39;td&#39;); } else { data = $(this).parents(&#39;tr&#39;).prev().eq(0).find(&#39;td&#39;); } var id = data.eq(0).html(); var fname = data.eq(1).html(); var lname = data.eq(2).html(); var email = data.eq(3).html(); $(&#39;[id*=txtId]&#39;).val(id); $(&#39;[id*=txtName]&#39;).val(fname); $(&#39;[id*=txtemail]&#39;).val(email); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id=&#34;form1&#34; runat=&#34;server&#34;&gt; &lt;table id=&#34;tbtUpdate&#34; class=&#34;table&#34;&gt; &lt;tr&gt; &lt;td&gt; Id &lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID=&#34;txtId&#34; runat=&#34;server&#34;&gt;&lt;/asp:TextBox&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Name &lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID=&#34;txtName&#34; runat=&#34;server&#34;&gt;&lt;/asp:TextBox&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Data &lt;/td&gt; &lt;td&gt; &lt;asp:TextBox ID=&#34;txtLink&#34; runat=&#34;server&#34;&gt;&lt;/asp:TextBox&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align=&#34;center&#34;&gt; &lt;asp:Button ID=&#34;Button1&#34; Text=&#34;Update&#34; runat=&#34;server&#34; class=&#34;btn btn-primary&#34; /&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;br /&gt; &lt;div style=&#34;width: 100%; border: 1px solid black; padding: 3px&#34;&gt; &lt;table id=&#34;datatable&#34; class=&#34;table table-striped table-bordered dt-responsive nowrap&#34; cellspacing=&#34;0&#34; width=&#34;100%&#34;&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt; Id &lt;/th&gt; &lt;th&gt; f_Name &lt;/th&gt; &lt;th&gt; Data &lt;/th&gt; &lt;th&gt; Edit &lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;/table&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</pre> <p><strong>WebService.cs</strong></p> <pre class="brush: csharp">using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using System.Configuration; using System.Data.SqlClient; using System.Data; using System.Web.Script.Serialization; /// &lt;summary&gt; /// Summary description for WebService /// &lt;/summary&gt; [WebService(Namespace = &#34;http://tempuri.org/&#34;)] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. [System.Web.Script.Services.ScriptService] public class WebService : System.Web.Services.WebService { public class File { public int Id { get; set; } public string Name { get; set; } public string Data { get; set; } } [WebMethod] public void GetFiles() { string cs = ConfigurationManager.ConnectionStrings[&#34;constr&#34;].ConnectionString; List&lt;File&gt; files = new List&lt;File&gt;(); using (SqlConnection con = new SqlConnection(cs)) { SqlCommand cmd = new SqlCommand(&#34;SELECT TOP 2 id,Name,Data FROM tblFiles WHERE ContentType = &#39;image/jpeg&#39;&#34;, con); cmd.CommandType = CommandType.Text; con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { File file = new File(); file.Id = Convert.ToInt32(rdr[&#34;id&#34;]); file.Name = rdr[&#34;Name&#34;].ToString(); file.Data = Convert.ToBase64String((byte[])rdr[&#34;Data&#34;]); files.Add(file); } } JavaScriptSerializer js = new JavaScriptSerializer(); Context.Response.Write(js.Serialize(files)); } } </pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://i.imgur.com/ntZ0VsQ.gif" alt="" width="250" height="505" /></p> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/210792/Solved-Bootstrap-DataTable-row-Button-Click-not-working-in-Mobile-View-in-ASPNet/https://www.aspforums.net:443/Threads/210792/Solved-Bootstrap-DataTable-row-Button-Click-not-working-in-Mobile-View-in-ASPNet/Fri, 12 Jul 2019 07:04:20 GMT