ASP参数未传递给JavaScript

时间:2017-05-06 14:14:35

标签: javascript c# html asp.net

这是我的ASP代码

string studentid = dr["StudentId"].ToString();
        string studentname = dr["studentName"].ToString();
        Response.Write("<tr>");
        Response.Write("<td id = 'sid' >");
        Response.Write(studentid);
        Response.Write("</td>");
        Response.Write("<td>");
        Response.Write(studentname);
        Response.Write("</td>");
        Response.Write(String.Format("<td id = '{0}' onclick = 'update({0})' >", studentid));
        Response.Write("<img src = 'Edit-icon.png' height='20' width='20' >");
        Response.Write("</td>");
        Response.Write(String.Format("<td id = '{0}' onclick = 'deleteStudent({0})' >", studentid));
        Response.Write("<img src = 'ic_delete_48px-128.png' height='20' width='20'>");
        Response.Write("</td>");
        Response.Write("</tr>");
    }

每当我点击td id =&#34; studentid&#34;正在调用JavaScript函数但参数未传递。 这是我的JavaScript函数:

function deleteStudent(x) {

        alert(x);
        var ajaxRequest = new XMLHttpRequest;
        ajaxRequest.open("GET", "crudops.aspx?StudentId=" + x +"&operation=delete", false);
        ajaxRequest.send(null);
        ...

这里警告(x)说[对象HTMLCollection] 问题是什么? 帮助我提出建议。

0 个答案:

没有答案