Have you inserted service refrence in your solution ?
If not add to your solution and make change in webconfig file as
eg:
my webservice method:
[WebMethod]
public int insertRecord( string sName, string sAge, string sSalary, string sCountry, string sCity)
{
var con = new SqlConnection(ConnectionState());
con.Open();
var cmd = new SqlCommand("Insert into EMaster(Name,Age, Salary, Country,City) values( '" + sName + "','" + sAge + "','" + sSalary + "','" + sCountry + "','"+ sCity + "')", con);
int row = cmd.ExecuteNonQuery();
return row;
}
and web.config:
<applicationSettings>
<EmployeeDetails.Properties.Settings>
<setting name="EmployeeDetails_localhost_Service1" serializeAs="String">
<value>http://localhost:50656/Service1.asmx</value>
</setting>
</EmployeeDetails.Properties.Settings>
</applicationSettings>
and in code behnd files use like this
protected void Addbutton_Click(object sender, EventArgs e)
{
txtid.Enabled = false;
localhost.Service1 dbws = new localhost.Service1();
if ((txtName.Text == "") || (txtage.Text == "") || (txtsalary.Text == "") || (txtcountry.Text == "") || (txtcity.Text == ""))
{ Response.Write("<script>alert('Record not insert-Rows Cannot be null');</script>"); }
else
{
int row = dbws.insertRecord(txtName.Text, txtage.Text, txtsalary.Text, txtcountry.Text, txtcity.Text);
if (row > 0)
{
Response.Write("<script>alert('Record insert successfuly');</script>");
txtid.Text=txtName.Text = txtage.Text = txtsalary.Text = txtcountry.Text = txtcity.Text = "";
getId();
FillGrid();
ddlSelect_SelectedIndexChanged(sender, e);
}
else { Response.Write("<script>alert('Record not insert');</script>"); }
}
}
here service1 is my webservice name.