动态添加文件上载控件会出错

时间:2012-12-21 07:09:11

标签: c# javascript asp.net

我正在尝试按照本指南动态创建文件上传控件。

http://humrahimcs.wordpress.com/2011/04/15/dynamically-create-multiple-file-upload-control-with-asp-net-c/

但是当我最终提交表单时,我收到连接重置错误而没有任何更多信息。我究竟做错了什么?

    function AddNewRow() {

        var rownum = 1;

        var div = document.createElement("div");

        var divid= "dv" + rownum;

        div.setAttribute("ID",divid);

        rownum++;

        var lbl = document.createElement("label");

        lbl.setAttribute("ID", "lbl" + rownum);

        lbl.setAttribute("class", "label1");

        lbl.innerHTML = "Imagen: ";

        rownum++;

        var _upload = document.createElement("input");

        _upload.setAttribute("type", "file");

        _upload.setAttribute("ID", "upload" + rownum);

        _upload.setAttribute("runat", "server");

        _upload.setAttribute("name","uploads"+rownum)

        rownum++;

        var hyp = document.createElement("a");

        hyp.setAttribute("style", "cursor:Pointer");

        hyp.setAttribute("onclick", "return RemoveDv('" + divid + "');");

        hyp.innerHTML = "Remover";

        rownum++;

        var br=document.createElement("br");

        var _pdiv = document.getElementById("Parent");

        div.appendChild(br);

        div.appendChild(lbl);

        div.appendChild(_upload);

        div.appendChild(hyp);

        _pdiv.appendChild(div);

    }

    function RemoveDv(obj) {

        var p = document.getElementById("Parent");

        var chld = document.getElementById(obj);

        p.removeChild(chld);

    }

</script>

0 个答案:

没有答案