Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a asp.net webforms textbox in which I have loaded data form datatable on page load, it works fine but when I put ng-model in this, the textbox becomes blanks.
I need data from datatable as well as do some calculation in angular js .
<asp:TextBox ID="txtCp" CssClass="form-control" ng-model="cp" ng-change="ACP()" runat="server">

What I have tried:

C#
if (!IsPostBack)
{
    try
    {
        DataTable dt2 = bllproduct.GetProductById(productId);
        if (dt2.Rows.Count > 0)
        {                   
            txtCp.Text = Convert.ToDouble(dt2.Rows[0]["CostPrice"]).ToString();
           
        }

Angular:

JavaScript
app.controller('ProductController', function ($scope) {
    $scope.vat=13;
    $scope.ACP = function () {
        $scope.acp = ($scope.cp - (-$scope.cp * ($scope.vat / 100)));
    }
    $scope.SP = function () {
        $scope.sp = ($scope.acp - (-$scope.acp * ($scope.margin / 100)));
    }
});

ASP.NET
<asp:TextBox ID="txtCp" CssClass="form-control" ng-model="cp" ng-change="ACP()" runat="server">
Posted
Updated 11-Jul-17 17:51pm
v2

1 solution

try

app.controller('ProductController', function ($scope) {
            $scope.cp = document.getElementById('<%=  txtCp.ClientID%>').value;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900