I have a javascript function that is working fine in default.aspx when click on a link button. However, when I call this function from code behind, it cant work.
Here is part of my code in default.aspx :
function loadAdditionalInfoDialog(qtyId)
{
alert(qtyId);
var qty = document.getElementById(qtyId).value;
alert(qty);
}
Here is part of my code in code behind (default.aspx.cs) when click on a button:
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);
}
The alert(qtyId) is working for both side and print out the same word. (default page and code behind). But code behind fail to alert(qty). Anyone know what is my problem?
Noted that the qtyId is a text box id inside a repeater in default.aspx.