I want to capture web cam images and save them in the database. It works properly. There are two web pages. When a button clicked in the Page1, it opens a popup (Page2) for capture the image.
Page1
Page2
After clicking the submit button, it saves the image in the database by UploadPic() function and closes itself. I want to reload the Page1 again to show the last captured image within it. It reloads, but it executes the button click event automatically and open the popup again. I want to stop that. I think the problem is within the UploadPic() function.
function UploadPic() {
debugger;
// generate the image data
var canvas = document.getElementById("canvas");
var dataURL = canvas.toDataURL("image/png");
// Sending the image data to Server
$.ajax({
type: 'POST',
url: "baseimg.aspx",
data: { imgBase64: dataURL },
success: function () {
alert("Done, Picture Uploaded.");
window.opener.location.reload(true); // reloading Parent page
window.close();
window.opener.setVal(1);
return false;
}
});
}
Any help would be really appreciated..
I don't know about ASP, but this is what I have found.
Try this to your submit button:
protected void yoursavebutton_Click(object sender, EventArgs e)
{
UploadPic();
Response.Redirect("page1.aspx");
}
Or Put this to your child page(Page 2) <body onunload="opener.location=opener.location;">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.