javascript - issues with dynamically creating a file upload control -


i trying create file upload control dynamically updating word documents. have following code in aspx page.

  <asp:gridview id="gvdetails" runat="server" autogeneratecolumns="false" datakeynames="filepath" emptydatatext="no documents attached" >                                <headerstyle backcolor="purple" font-bold="true" forecolor="white"  />                               <columns>                                   <asp:templatefield headertext="filepath">                                       <itemtemplate>                                           <asp:linkbutton id="lnkdownload" runat="server" text="my document" onclick="lbdownloaddocument_click"></asp:linkbutton>                                     <img src="image/delete.jpg" alt="" onclick="addfile()" /><br />                                      <br />                                           <asp:button id="button1" runat="server" text="update" onclick="button2_click" />                                       </itemtemplate>                                   </asp:templatefield>                               </columns>                            </asp:gridview> 

i have following code in .cs page.

   protected void button2_click(object sender, eventargs e)     {         (int = 0; < request.files.count; i++)         {             httppostedfile postedfile = request.files[i];             if (postedfile.contentlength > 0)             {                 string filename = system.io.path.getfilename(postedfile.filename);                 postedfile.saveas(server.mappath("~/files/") + filename);             }         }     } 

and script :

    <script type="text/javascript">         var = 1;         function addfile() {             i++;             var div = document.createelement('div');             div.innerhtml = '<input id="file' + + '" name = "file' + + '" type="file" /><img src="~/image/delete.jpg" alt="remove" onclick = "removefile(this)" />';             document.getelementbyid("divfile").appendchild(div);         }         function removefile(file) {             document.getelementbyid("divfile").removechild(file.parentnode);         }     </script> 

but somehow code not working. don't have idea of file upload control. please me it. should use update panel ?


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -