0

我有一个 javascript 函数,我正在调用多个控件,但它似乎只调用第一个 ClientScript.RegisterStartupScript。

 ClientScript.RegisterStartupScript(this.GetType(), "myScript", "textCounter('" + txtCourseDesc.ClientID + "','" + txtRemDesc.ClientID + "', '2000')", true);
 ClientScript.RegisterStartupScript(this.GetType(), "myScript", "textCounter('" + txtReqCourseCode.ClientID + "','" + txtRemCode.ClientID + "', '90')", true);
 ClientScript.RegisterStartupScript(this.GetType(), "myScript", "textCounter('" + txtPReq.ClientID + "','" + txtPreqRem.ClientID + "', '1000')", true);

请指出问题。

4

1 回答 1

0

您不能对具有不同参数的一个功能使用相同的键。尝试这个:

 ClientScript.RegisterStartupScript(this.GetType(), "myScript2000", "textCounter('" + txtCourseDesc.ClientID + "','" + txtRemDesc.ClientID + "', '2000')", true);
 ClientScript.RegisterStartupScript(this.GetType(), "myScript90", "textCounter('" + txtReqCourseCode.ClientID + "','" + txtRemCode.ClientID + "', '90')", true);
 ClientScript.RegisterStartupScript(this.GetType(), "myScript1000", "textCounter('" + txtPReq.ClientID + "','" + txtPreqRem.ClientID + "', '1000')", true);
于 2013-02-19T11:42:37.197 回答