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 enter image description here

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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -