我正在使用“ ScriptManager.RegisterClientScriptBlock(this, typeof(string), "uniqueKey", jsMethodName, true);”從 C# 代碼隱藏中調用 JavaScript 函數。它工作正常。但是,問題是當我使用循環時for (i = 0; i < count; i++) { string jsMethodName = "javascripttestfunction('" + parameter[i] + "','" + param[i] + "','" + param[i] + "','" + param[i] + "','" + param[i] + "')"; // callig javascript function from codebehind ScriptManager.RegisterClientScriptBlock(this, typeof(string), "uniqueKey", jsMethodName, true);}它只需要第一組參數。它不需要剩余的集合。
1 回答

慕運維8079593
TA貢獻1876條經驗 獲得超5個贊
腳本管理器需要不同的鍵,所以請嘗試下面的代碼。
for (i = 0; i < count; i++) {
string jsMethodName = "javascripttestfunction('" + param[i] + "','" +
param[i] + "','" + param[i] + "','" + param[i] + "','" + param[i] + "')"; // callig javascript function from codebehind
ScriptManager.RegisterClientScriptBlock(this, typeof(string), "uniqueKey"+i, jsMethodName, true);
}
- 1 回答
- 0 關注
- 152 瀏覽
添加回答
舉報
0/150
提交
取消