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.Display Birthday greetings using AnjularJS in ASP.Net MVC<p>Hi <a class="username" rel="mahesh213"> mahesh213</a>,</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 ActionResult Index() { return View(); } [HttpPost] public JsonResult GreetingMessage() { string message = &#34;&#34;; // Runs at every dat 12 AM. if (DateTime.Now.Hour == 0 &amp;&amp; DateTime.Now.Minute == 0) { // Assign Greeting message whose DOB falls on Today&#39;s Date based on LoggedIn User. string query = &#34;SELECT Name FROM Employee WHERE DATEPART(DAY, DOB) = @Day AND DATEPART(MONTH, DOB) = @Month AND Name = @Name&#34;; string constr = ConfigurationManager.ConnectionStrings[&#34;constr&#34;].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand(query)) { cmd.Connection = con; cmd.Parameters.AddWithValue(&#34;@Day&#34;, DateTime.Today.Day); cmd.Parameters.AddWithValue(&#34;@Month&#34;, DateTime.Today.Month); cmd.Parameters.AddWithValue(&#34;@Name&#34;, Session[&#34;UserName&#34;]); con.Open(); message = string.Format(&#34;&lt;b&gt;Happy Birthday &lt;/b&gt;{0}&lt;br /&gt;&lt;br /&gt;Many happy returns of the day.&#34;, Session[&#34;UserName&#34;]); con.Close(); } } } return Json(message); } }</pre> <p><strong><span style="text-decoration: underline;">View</span></strong></p> <pre class="brush: html">&lt;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&gt; &lt;head&gt; &lt;title&gt;Index&lt;/title&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.8/angular.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; var app = angular.module(&#34;MyApp&#34;, []); app.controller(&#34;MyController&#34;, function ($scope, $http, $sce) { DisplayGreeting(); function DisplayGreeting() { $http({ method: &#34;POST&#34; , url: &#34;Home/GreetingMessage/&#34; }).then(function (response) { if (response.data != &#39;&#39;) { $scope.Message = $sce.trustAsHtml(response.data); } }, function (response) { $scope.Message = response.responceText; }) } }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div ng-app=&#34;MyApp&#34; ng-controller=&#34;MyController&#34;&gt; &lt;div style=&#34;z-index: 1; position: relative; background-color: #0090CB; width: 20%; height: 100%; padding: 20px; color: white; text-align: center;&#34;&gt; &lt;span ng-bind-html=&#34;Message&#34;&gt;&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/185125/Display-Birthday-greetings-using-AnjularJS-in-ASPNet-MVC/https://www.aspforums.net:443/Threads/185125/Display-Birthday-greetings-using-AnjularJS-in-ASPNet-MVC/Fri, 06 Sep 2019 06:10:05 GMT