I am trying to call the method insert which is in Edit.aspx.cs but it is not calling
<script src="jquery-2.0.2.js"></script>
<script language="javascript">
function insert() {
$.ajax({
type: "POST",
url: "Edituser.aspx.cs/insert",
success: function () { alert('success'); },
error: function () { alert('error'); }
});
}
</script>
<input type="button" id="Button1" style="display: none" onclick="changecourse(); insert();" value="add" />
My codebehind
public void insert()
{
string a = Hidden1.Value;
string UserId = Convert.ToString(Session["LoginId"]);
con.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO UserDepot (UserId,DepotId)" +
"VALUES ('" + UserId + "','" + a + "')", con);
cmd.ExecuteNonQuery();
con.Close();
}
.csfile like that... cfr Milind's answer here under.