[英]How to call Multiple Java Script function into code behind C#
How to call Multiple Java Script function into code behind C#. 如何在C#之后的代码中调用多个Java脚本函数。 I want to call below two function into code behind c#. 我想在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>
I have requirement to take a photo from web camera, in first time in f1() function I am showing ajax modal popup for taking photo and user will submit. 我要求从网络摄像机拍摄照片,第一次在f1()函数中,我正在显示ajax模版弹出照片,用户将提交。 And second time taking photo directly to calling another function takepic(). 第二次直接拍照以调用另一个函数takepic()。
I tried but not getting. 我尝试了但没有得到。
if (QSno == "1")
{
Page.ClientScript.RegisterStartupScript(this.GetType(),"CallMyFunction","f1()",true)
}
else if (QSno == "2")
{
Page.ClientScript.RegisterStartupScript(this.GetType(),"CallMyFunction","takepic()",true)
}
Actually you are registering the same type/key combination more than once, You have to use different for every registration. 实际上,您多次注册相同的类型/按键组合,每次注册都必须使用不同的类型。
So use different keys 所以用不同的键
if (QSno == "1")
{
Page.ClientScript.RegisterStartupScript(this.GetType(),"CallMyFunction","f1()",true)
}
else if (QSno == "2")
{
Page.ClientScript.RegisterStartupScript(this.GetType(),"CallMyFunction2","takepic()",true)
}
The script key here is CallMyFunction 此处的脚本键是CallMyFunction
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.