[英]how to call code behind function with parameter from java script function
[英]How to call Multiple Java Script function into code behind C#
如何在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)
}
實際上,您多次注冊相同的類型/按鍵組合,每次注冊都必須使用不同的類型。
所以用不同的鍵
if (QSno == "1")
{
Page.ClientScript.RegisterStartupScript(this.GetType(),"CallMyFunction","f1()",true)
}
else if (QSno == "2")
{
Page.ClientScript.RegisterStartupScript(this.GetType(),"CallMyFunction2","takepic()",true)
}
此處的腳本鍵是CallMyFunction
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.