c# - All uploaded files are not displayed in the links -
i have written as
protected void btnupload_click(object sender, eventargs e) { httpfilecollection filecollection = request.files; (int = 0; < filecollection.count; i++) { httppostedfile uploadfile = filecollection[i]; string filename = path.getfilename(uploadfile.filename); if (uploadfile.contentlength > 0) { uploadfile.saveas(server.mappath("~/uploadfiles/") + filename); lblmessage.text += filename + "saved successfully<br>"; hyperlnk.text = filename.tostring() + "saved successfully<br>"; // hyperlnk.attributes.add("href", server.mappath("/uploadfiles/") + filename); hyperlnk.navigateurl="~/uploadfiles/" + filename; //lblmessage.text= "<a href=" + "/uploadfiles/" + filename +">"+filename+"</a>"; } } }
when upload multiple files, 1 of them displayed in link shown in screenshot
please me
you need add panel of type panel on page instead of hyperlnk , use container links code following:
panel.controls.clear(); (int = 0; < filecollection.count; i++) { httppostedfile uploadfile = filecollection[i]; string filename = path.getfilename(uploadfile.filename); if (uploadfile.contentlength > 0) { uploadfile.saveas(server.mappath("~/uploadfiles/") + filename); lblmessage.text += filename + "saved successfully<br>"; hyperlink dynamhyperlink = new hyperlink(); dynamhyperlink.text = filename.tostring() + "saved successfully<br>"; // hyperlnk.attributes.add("href", server.mappath("/uploadfiles/") + filename); dynamhyperlink.navigateurl = "~/uploadfiles/" + filename; panel.controls.add(dynamhyperlink); //lblmessage.text= "<a href=" + "/uploadfiles/" + filename +">"+filename+"</a>"; } }
Comments
Post a Comment