【发布时间】:2016-10-25 17:14:36
【问题描述】:
如何在 C# 后面的代码中调用多个 Java 脚本函数。我想在c#后面的代码中调用下面的两个函数。
<script type="text/javascript">
// dateFuture = new Date(2010, 11, 25, 12, 0, 0);
function f1()
{
$find("mpe").show();
return false;
}
function takepic() {
// first part
context.drawImage(video, 0, 0, 320, 240);
//above line take the picture
//second part save the picture
var image = document.getElementById("canvas").toDataURL("image/png");
alert(image);
//get raw image data
image = image.replace('data:image/png;base64,', '');
$.ajax({
type: "POST",
url: "assessment.aspx/SaveUser",
data: '{"imageData": "' + image + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert("User has been added successfully.");
window.location.reload();
}
});
return false;
}
</script>
我需要从网络摄像头拍照,第一次在 f1() 函数中显示用于拍照的 ajax 模态弹出窗口,用户将提交。第二次拍照直接调用另一个函数takepic()。
我试过了,但没有得到。
if (QSno == "1")
{
Page.ClientScript.RegisterStartupScript(this.GetType(),"CallMyFunction","f1()",true)
}
else if (QSno == "2")
{
Page.ClientScript.RegisterStartupScript(this.GetType(),"CallMyFunction","takepic()",true)
}
【问题讨论】:
标签: javascript c# jquery asp.net