Insert data in using indexedDB. This is what i tried.
On page load am using ScriptManager to call a client side javascript function and passing 2 variables id_ and session_id_
String id_ = "10";
String session_id_ = System.Web.HttpContext.Current.Session.SessionID;
ScriptManager.RegisterStartupScript(this, GetType(), "", "add('" + id_ + "','" + session_id_ + "');", true);
The code works find when the 2 variables(id_,session_id_) are hardcoded and use onclick = "add()".
But when i run it as it is db.transaction(["user_session"], "readwrite") is underline says that Uncaught TypeError: Cannot read properties of undefined (reading 'transaction')
Javascript function
function add(id_, session_id_) {
console.log(id_);
console.log(session_id_);
var request = db.transaction(["user_session"], "readwrite")
.objectStore("user_session")
.add({ id: id_, session_id: session_id_});
request.onsuccess = function (event) {
alert("data added successfully");
};
request.onerror = function (event) {
alert("Unable to add data aready exist in database! ");
}
}