Microsoft JScript 运行时错误: Sys.ParameterCountException: 参数计数不匹配。
使用后台生成按钮并添加按钮点击事件,运行时,多次点击按钮报错,报错的页面是系统的ScriptResource.axd?………………(一长串),提示内容如标题“Microsoft JScript 运行时错误: Sys.ParameterCountException: 参数计数不匹配。”
报错的页面系统自带函数:
Function.emptyFunction = Function.emptyMethod = function Function$emptyMethod() {
/// <summary locid="M:J#Function.emptyMethod" />
if (arguments.length !== 0) throw Error.parameterCount();
}
生成按钮后添加
btn.Click += new System.EventHandler(this.NewBtnClick);
Click事件响应的函数:
protected void NewBtnClick(object sender, EventArgs e)
{
Button xBtn = (Button)sender;
xBtn.CssClass = "downbtcss";
OleDbConnection conn = null;
string sql = "Select ID FROM 点标注 Where 简称= '" + xBtn.Text + "'";
string accessDbPath = String.Empty;
accessDbPath = HttpContext.Current.Server.MapPath("~/App_Data/数据表.mdb");
conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + accessDbPath);
OleDbCommand cmd = new OleDbCommand(sql, conn);
OleDbDataReader reader=null;
try
{
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
reader = cmd.ExecuteReader();
string tmp = "";
while (reader.Read())
{
tmp = reader[0].ToString();
}
ScriptManager.RegisterStartupScript(this, this.GetType(), "", "bianhao12('" + tmp + "');", true);
}
catch (Exception ex)
{
Response.Write(ex);
}
finally
{
reader.Close();
conn.Close();
}
}
现在的问题是我找不到问题的根源在哪里。求助!!!
------解决方案--------------------你使用的是UpdatePanel?
------解决方案--------------------try
{
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
reader = cmd.ExecuteReader();
string tmp = "";
while (reader.Read())
{
tmp = reader[0].ToString();
}
=>
try
{
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
reader = cmd.ExecuteReader();
string tmp = "";
if (reader.Read())
{
tmp = reader[0].ToString();
}
------解决方案--------------------
------解决方案--------------------你在 NewBtnClick 中 加断点跟一下,看看 实际错误是什么
------解决方案--------------------问题可能在你的 NewBtnClick 方法中
------解决方案--------------------错误不是每次都出现?
Response.Write(ex);
=>
ScriptManager.RegisterStartupScript(this, this.GetType(), "error", "alert('"+ex.Message+"');", true);
------解决方案--------------------你最好找下错误的规律