单击链接按钮时,我有一个在 default.aspx 中运行良好的 javascript 函数。但是,当我从后面的代码中调用此函数时,它无法工作。
这是我在 default.aspx 中的部分代码:
function loadAdditionalInfoDialog(qtyId)
{
alert(qtyId);
var qty = document.getElementById(qtyId).value;
alert(qty);
}
单击按钮时,这是我在代码后面(default.aspx.cs)中的部分代码:
protected void btnRedeemAll_Click(object sender, EventArgs e){
TextBox txtQty = (TextBox)itm.FindControl("txtQty");
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", "<script>loadAdditionalInfoDialog(" + txtQty.ClientID + ")</script>", false);
}
alert(qtyId) 对双方都有效并打印出相同的单词。(默认页面和后面的代码)。但是后面的代码无法提醒(数量)。有谁知道我的问题是什么?
请注意,qtyId 是 default.aspx 中转发器内的文本框 ID。