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.Populate (Fill) multiple TextBox based on DropDownList selection using AngularJS in ASP.Net<p>Hi&nbsp;rani,</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">Database</span></strong></p> <p>For this example I have used of Northwind database that you can download using the link given below.</p> <p><a href="https://www.aspsnippets.com/Articles/Install-Microsoft-Northwind-and-Pubs-Sample-databases-in-SQL-Server-Management-Studio.aspx" target="_blank">Download Northwind Database</a></p> <p><strong><span style="text-decoration: underline;">HTML</span></strong></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;link rel=&#34;stylesheet&#34; href=&#34;https://netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css&#34; /&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/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;, [&#39;$scope&#39;, &#39;$http&#39;, function ($scope, $http) { GetCategory(); $scope.IsDisabled = true; $scope.GetProducts = function () { if ($scope.CategoryName != null) { $http.post(&#34;Default.aspx/GetProducts&#34;, { category: $scope.CategoryName }, { headers: { &#39;Content-Type&#39;: &#39;application/json&#39;} }) .then(function (response) { $scope.ProductName1 = eval(response.data.d)[0] != undefined ? eval(response.data.d)[0].ProductName : &#34;&#34;; $scope.ProductName2 = eval(response.data.d)[1] != undefined ? eval(response.data.d)[1].ProductName : &#34;&#34;; $scope.ProductName3 = eval(response.data.d)[2] != undefined ? eval(response.data.d)[2].ProductName : &#34;&#34;; }, function error(response) { }); } else { $scope.ProductName1 = &#34;&#34;; $scope.ProductName2 = &#34;&#34;; $scope.ProductName3 = &#34;&#34;; } $scope.IsDisabled = $scope.CategoryName == null ? true : false; } function GetCategory() { $scope.categories = []; $http.post(&#34;Default.aspx/GetCategories&#34;, { headers: { &#39;Content-Type&#39;: &#39;application/json&#39;} }) .then(function (response) { $scope.categories = eval(response.data.d); }, function error(response) { }); } } ]); &lt;/script&gt; &lt;/head&gt; &lt;body ng-app=&#34;MyApp&#34; ng-controller=&#34;MyController&#34;&gt; &lt;form id=&#34;form1&#34; runat=&#34;server&#34;&gt; &lt;div class=&#34;form-horizontal&#34;&gt; &lt;div class=&#34;form-row&#34;&gt; &lt;div class=&#34;col-md-3&#34;&gt; &lt;label for=&#34;CategoryName&#34;&gt;Category&lt;/label&gt; &lt;select class=&#34;form-control&#34; id=&#34;CategoryName&#34; ng-change=&#34;GetProducts()&#34; ng-model=&#34;CategoryName&#34; ng-options=&#34;c.CategoryId as c.CategoryName for c in categories&#34;&gt; &lt;option value=&#34;&#34;&gt;Select Item&lt;/option&gt; &lt;/select&gt; &lt;br /&gt; &lt;label for=&#34;ProductName1&#34;&gt;Product 1&lt;/label&gt; &lt;input type=&#34;text&#34; ng-model=&#34;ProductName1&#34; ng-disabled=&#34;IsDisabled&#34; class=&#34;form-control&#34; /&gt; &lt;br /&gt; &lt;label for=&#34;ProductName2&#34;&gt;Product 2&lt;/label&gt; &lt;input type=&#34;text&#34; ng-model=&#34;ProductName2&#34; ng-disabled=&#34;IsDisabled&#34; class=&#34;form-control&#34; /&gt; &lt;br /&gt; &lt;label for=&#34;ProductName3&#34;&gt;Product 3&lt;/label&gt; &lt;input type=&#34;text&#34; ng-model=&#34;ProductName3&#34; ng-disabled=&#34;IsDisabled&#34; class=&#34;form-control&#34; /&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</pre> <p><strong><span style="text-decoration: underline;">Namespaces</span></strong></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Web.Script.Serialization; using System.Web.Services;</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports System.Web.Script.Serialization Imports System.Web.Services</pre> <p><strong><span style="text-decoration: underline;">Code</span></strong></p> <p><strong>C#</strong></p> <pre class="brush: csharp">[WebMethod] public static string GetCategories() { NorthwindEntities entities = new NorthwindEntities(); var categories = entities.Categories .Select(x =&gt; new { CategoryId = x.CategoryID, CategoryName = x.CategoryName }).ToList(); return (new JavaScriptSerializer().Serialize(categories)); } [WebMethod] public static string GetProducts(int category) { NorthwindEntities entities = new NorthwindEntities(); var products = entities.Products .Where(x =&gt; x.CategoryID == category).Take(3) .Select(x =&gt; new { ProductID = x.ProductID, ProductName = x.ProductName }).ToList(); return (new JavaScriptSerializer().Serialize(products)); }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">&lt;WebMethod()&gt; Public Shared Function GetCategories() As String Dim entities As NorthwindEntities = New NorthwindEntities() Dim categories = entities.Categories.Select(Function(x) New With { .CategoryId = x.CategoryID, .CategoryName = x.CategoryName }).ToList() Return (New JavaScriptSerializer().Serialize(categories)) End Function &lt;WebMethod()&gt; Public Shared Function GetProducts(ByVal category As Integer) As String Dim entities As NorthwindEntities = New NorthwindEntities() Dim products = entities.Products.Where(Function(x) x.CategoryID = category).Take(3).Select(Function(x) New With { .ProductID = x.ProductID, .ProductName = x.ProductName }).ToList() Return (New JavaScriptSerializer().Serialize(products)) End Function</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/YF7z2xl.gif" alt="" width="277" height="292" /></span></strong></p>https://www.aspforums.net:443/Threads/974682/Populate-Fill-multiple-TextBox-based-on-DropDownList-selection-using-AngularJS-in-ASPNet/https://www.aspforums.net:443/Threads/974682/Populate-Fill-multiple-TextBox-based-on-DropDownList-selection-using-AngularJS-in-ASPNet/Fri, 29 Mar 2019 03:37:28 GMT