Ibrahim Shaikh Ibrahim Shaikh - 11 months ago 55
ASP.NET (C#) Question

how to pass parameters from textbox to web service using angular

I am creating a web app in which i am getting my data from

now i can use json and webservice where i dont need where clause but now i want a particular data(like i just want to see record number (1) in 100 records) how to do it

here is my web service where i declare a string as id

public void GetEmployessJSON(string id)
SqlConnection con = new SqlConnection(connectionstring);
List<object> list = new List<object>();
SqlCommand cmd = new SqlCommand("select * from authors where AuthorId='"+id.ToString()+"'", con);

SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
AuthorId = dr["AuthorId"],
Fname = dr["Fname"],
Lname = dr["Lname"]
var jsonSerialiser = new JavaScriptSerializer();
var json = jsonSerialiser.Serialize(list);

Context.Response.Write("{" + '"' + "info" + '"' + ":" + json + "}");


and the id will come from the textbox in aspx page
this is my aspx page

<form id="form1" runat="server">
<asp:TextBox ID="txtid" runat="server"></asp:TextBox>
<div ng-app="myApp" ng-controller="customersCtrl">
<table class="table">
<tr class="bg-primary">
<th>Author ID</th>
<tr ng-repeat="x in names">
<td>{{ x.AuthorId }}</td>
<td>{{ x.Fname }}</td>
<td>{{ x.Lname }}</td>
<td><asp:Button ID="btndelete" runat="server" Text="Delete" /></td>

<div id="Java Scripts">
<script src="JavaScript.js"></script>

this is my js

var app = angular.module('myApp', []);
app.controller('customersCtrl', function ($scope, $http) {
.then(function (response) {
$scope.names = response.data.info;

Answer Source

You Need To Create another method in JS and pass id(which you used in webservice) in that js file and declare a variable pass the id to variable (var id) and give pass the value of the variable into the textbox {{id}} and on button click event you can do what you wants