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.Bind Hyperlink (Anchor Tag) from database in ASP.Net MVC<p>Hi&nbsp;mahesh213,</p> <p>Check this example. Now please take its reference and correct your code.</p> <p>Here i am passing DataTable as model to the view.</p> <p><strong><span style="text-decoration: underline;">Controller</span></strong></p> <pre class="brush: csharp">public class HomeController : Controller { // GET: /Home/ public ActionResult Index() { DataTable dt = new DataTable(); dt.Columns.Add(&#34;Id&#34;); dt.Columns.Add(&#34;ControllerName&#34;); dt.Columns.Add(&#34;Url&#34;); dt.Rows.Add(1, &#34;Report&#34;, &#34;/report/Index/&#34;); dt.Rows.Add(2, &#34;Report1&#34;, &#34;/report1/Index1/&#34;); return View(dt); } }</pre> <p><strong><span style="text-decoration: underline;">View</span></strong></p> <pre class="brush: html">&lt;%@ Page Language=&#34;C#&#34; Inherits=&#34;System.Web.Mvc.ViewPage&lt;System.Data.DataTable&gt;&#34; %&gt; &lt;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&gt; &lt;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&gt; &lt;head runat=&#34;server&#34;&gt; &lt;title&gt;Index&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h4&gt;An Unordered List:&lt;/h4&gt; &lt;ul&gt; &lt;%foreach (System.Data.DataRow dr in Model.Rows) {%&gt; &lt;li&gt; &lt;a href=&#39;&lt;%=dr[&#34;Url&#34;] %&gt;&#39;&gt;&lt;%=dr[&#34;ControllerName&#34;]%&gt;&lt;/a&gt; &lt;/li&gt; &lt;%} %&gt; &lt;/ul&gt; &lt;/body&gt; &lt;/html&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/vvT84Sb.jpg" alt="" width="251" height="177" /></span></strong></p>https://www.aspforums.net:443/Threads/165337/Bind-Hyperlink-Anchor-Tag-from-database-in-ASPNet-MVC/https://www.aspforums.net:443/Threads/165337/Bind-Hyperlink-Anchor-Tag-from-database-in-ASPNet-MVC/Thu, 11 Jul 2019 07:22:45 GMTBind Hyperlink (Anchor Tag) from database in ASP.Net MVC<p>Thanks for your's reply</p> <p>Could you please provide me solution without using razor view engine(@)</p> <p>I need code only using jquery/javascript and MVC</p> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/165337/Bind-Hyperlink-Anchor-Tag-from-database-in-ASPNet-MVC/https://www.aspforums.net:443/Threads/165337/Bind-Hyperlink-Anchor-Tag-from-database-in-ASPNet-MVC/Fri, 12 Jul 2019 01:40:14 GMTBind Hyperlink (Anchor Tag) from database in ASP.Net MVC<p>Hi&nbsp;mahesh213,</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">Controller</span></strong></p> <pre class="brush: csharp">public class HomeController : Controller { // GET: /Home/ public JsonResult Index() { List&lt;SelectListItem&gt; lists = new List&lt;SelectListItem&gt;(); lists.Add(new SelectListItem { Text = &#34;Report&#34;, Value = &#34;/report/Index/&#34; }); lists.Add(new SelectListItem { Text = &#34;Report1&#34;, Value = &#34;/report1/Index1/&#34; }); return Json(lists, JsonRequestBehavior.AllowGet); } }</pre> <p><strong><span style="text-decoration: underline;">View</span></strong></p> <pre class="brush: html">&lt;script type=&#34;text/javascript&#34; src=&#34;http://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; $(function () { $.ajax({ type: &#34;POST&#34;, url: &#34;/Home/Index&#34;, contentType: &#34;application/json; charset=utf-8&#34;, dataType: &#34;json&#34;, success: function (r) { var ul = $(&#39;#unordered&#39;); $.each(r, function (i, item) { ul.append(&#34;&lt;li&gt;&lt;a href=&#39;&#34; + item.Value + &#34;&#39;&gt;&#34; + item.Text + &#34;&lt;/a&gt;&lt;/li&gt;&#34;); }); } }); }); &lt;/script&gt; &lt;h4&gt;An Unordered List:&lt;/h4&gt; &lt;ul id=&#34;unordered&#34;&gt;&lt;/ul&gt;</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><strong><img src="https://i.imgur.com/vvT84Sb.jpg" alt="" width="251" height="177" /></strong></p>https://www.aspforums.net:443/Threads/165337/Bind-Hyperlink-Anchor-Tag-from-database-in-ASPNet-MVC/https://www.aspforums.net:443/Threads/165337/Bind-Hyperlink-Anchor-Tag-from-database-in-ASPNet-MVC/Fri, 12 Jul 2019 06:42:46 GMT