As I develop a web application using AngularJS, I have a button that triggers a call to a web service.
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public void retrieveRecord(string id)
{
List<object> records = new List<object>();
SqlCommand cmd = new SqlCommand("select * from erp_admin.CompanySonVinUnitVenueRpt where comsonvinid in (select id from companysonvinunitvenue where id='"+id+"')",con);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
while(dr.Read())
{
records.Add(new
{
attendee1 = dr["comattendee1"].ToString(),
attendee2 = dr["comattendee2"].ToString(),
totalmale = dr["attendeetotalmale"].ToString(),
totalfemale = dr["attendeetotalfemale"].ToString(),
unit1 = dr["unitattendee1"].ToString(),
unitd1 = dr["unitattendee1desig"].ToString(),
unit2 = dr["unitattendee2"].ToString(),
unitd2 = dr["unitattendee2desig"].ToString(),
unit3 = dr["unitattendee3"].ToString(),
unitd3 = dr["unitattendee3desig"].ToString(),
unit4 = dr["unitattendee4"].ToString(),
unitd4 = dr["unitattendee4desig"].ToString(),
unit5 = dr["unitattendee5"].ToString(),
unitd5 = dr["unitattendee5desig"].ToString(),
remarks = dr["remarks"].ToString()
});
}
con.Close();
var json = js.Serialize(records);
Context.Response.Write("{" + '"' + "records" + '"' + ":" + json + "}");
}
The above webservice has been successfully tested and is functioning properly. This part of the code resides in my AngularJS file:
$scope.updatefunction = function (param) {
$http.get('/frmattendencerptqed.asmx/retrieveRecord', {
params: {
id: $scope.updateparam.comsonvinid
}
})
.then()
{
}
}
This snippet represents my AngularJS code
Additionally, this code represents my input field
<input type="text" ng-model="remarks" style="width:100%;" />
Currently, I am looking to retrieve the previous value from the database and populate the textbox with this value. If the user makes changes in the textbox, I want the value to be updated on button click.
How should I proceed with this implementation?