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.Sort TexArea value using jQuery in ASP.Net MVC<p>Hi&nbsp;<a class="username" rel="alya14">alya14,</a></p> <p>First create a JavaScript Array and add the value in the array. Then using the&nbsp;<strong>sort</strong> method to sort the record in acsending order and&nbsp;<strong>reverse</strong> method to sort the record in descending order and append to your TextArea.</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">Model</span></strong></p> <pre class="brush: csharp">public class QRCodeModel { public string Qrcode { get; set; } public string AddedQrcode { get; set; } }</pre> <p><strong><span style="text-decoration: underline;">Controller </span></strong></p> <pre class="brush: csharp">public class HomeController : Controller { // GET: /Home/ public ActionResult Index() { return View(new QRCodeModel()); } }</pre> <p><strong><span style="text-decoration: underline;">View</span></strong></p> <pre class="brush: html">&lt;body&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; $(document).ready(function () { var lists = []; $(&#39;#Qrcode&#39;).on(&#39;change&#39;, function () { lists.push($(this).val()); lists.sort(); $(&#34;#AddedQrcode&#34;).val(&#39;&#39;); $.each(lists, function (index, item) { if ($(&#34;#AddedQrcode&#34;).val() != &#39;&#39;) { $(&#34;#AddedQrcode&#34;).val($(&#34;#AddedQrcode&#34;).val() + &#34;\r\n&#34; + item); } else { $(&#34;#AddedQrcode&#34;).val(item); } }); lists.reverse(); $(&#34;#AddedQrcodem&#34;).val(&#39;&#39;); $.each(lists, function (index, item) { if ($(&#34;#AddedQrcodem&#34;).val() != &#39;&#39;) { $(&#34;#AddedQrcodem&#34;).val($(&#34;#AddedQrcodem&#34;).val() + &#34;\r\n&#34; + item); } else { $(&#34;#AddedQrcodem&#34;).val(item); } }); }); }); &lt;/script&gt; &lt;div&gt; &lt;%:Html.TextBoxFor(t =&gt; t.Qrcode, new { @autocomplete = &#34;off&#34;, @class = &#34;form-control&#34;, placeholder = &#34;&Uuml;r&uuml;n QR Kodu&#34; })%&gt;&lt;br /&gt; &lt;%:Html.TextAreaFor(t =&gt; t.AddedQrcode, new { style = &#34;font-size: 12px; font-weight: bold;overflow: scroll&#34;, rows = &#34;5&#34;, @autocomplete = &#34;off&#34;, @class = &#34;form-control&#34;, placeholder = &#34;Eklenen &Uuml;r&uuml;n Listesi&#34; })%&gt; &lt;%:Html.TextArea(&#34;AddedQrcodem&#34;, new { style = &#34;font-size: 12px; font-weight: bold;overflow: scroll&#34;, rows = &#34;5&#34;, @autocomplete = &#34;off&#34;, @class = &#34;form-control&#34;, placeholder = &#34;Eklenen &Uuml;r&uuml;n Listesi&#34; })%&gt; &lt;/div&gt; &lt;/body&gt;</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><strong><span style="text-decoration: underline;"><img src="https://i.imgur.com/MaWtD7t.gif" alt="" width="344" height="107" /></span></strong></p>https://www.aspforums.net:443/Threads/128441/Sort-TexArea-value-using-jQuery-in-ASPNet-MVC/https://www.aspforums.net:443/Threads/128441/Sort-TexArea-value-using-jQuery-in-ASPNet-MVC/Tue, 30 Jul 2019 07:15:01 GMT