jquery save method
<script type="text/javascript">
$(document).ready(function () {
$("#Button1").click(function () {
$.ajax({
type: 'POST',
contentType: "application/json;charset=utf-8",
url: 'Default2.aspx/InsertMethod',
data: "{'username':'" + document.getElementById('txtusername').value + "','password':'" + document.getElementById("txtpassword").value + "'}",
async: false,
success: function (response) {
$('#txtusername').val('');
$('#txtpassword').val('');
alert("record has been saved in database");
},
error: function () {
console.log('there is some error');
}
});
});
});
SqlCommand cmd = new SqlCommand("insert jquerydata values('" + username + "','" + password + "'", con);
[WebMethod]
public static string InsertMethod(string username, string password)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["con"].ConnectionString;
con.Open();
SqlCommand cmd = new SqlCommand("insert jquerydata values('" + username + "','" + password + "'", con);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
cmd.Dispose();
con.Close();
return "true";
}
Also in JavaScript:
- router flux pass props stack react native
- dispay react component after some time
- javascript key pressed enter
- jquery.treegrid.js
- Error: Cannot find module 'ejs'
- accept 2 values after decimal in angular forms
- javascript remove element
- angular pipe json error
- discord.js bot credits command
- prepend option on 2nd index jquery
- trim whitespace javascript
- optimized bubble sort javascript
- rounding off in javascript
- js destructuring explained
- node start is too slow windows 10
- === in js
- angular themeable components
- npx for windows
- chartjs lineTension
- express set response code
- props in react app
- create array of objects javascript
- javascript stringify line breaks
- javascript onclick to another page div