不刷新动态添加FileUpload

页面

 

    <tr>
        
<td align="right" style="height: 48px">
            
<asp:Label ID="Label8" runat="server" Text="附  件:" Width="100%"></asp:Label></td>
        
<td align="left" colspan="3" style="height: 48px">
        
<div id="MyFile" style="width:100%">
            
<asp:FileUpload ID="FileUpload1" runat="server" Width="80%" />       
            
</div>
            
<input id="btn_AddFile" type="button" runat="server" value="添加附件" />
        
</td>
    
</tr>

.cs中

 

 protected void Page_Load(object sender, EventArgs e)
    
{
        
//注册添加文件脚本
        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript",
        
"function addFile(btn)" +
        
"{ var str = '<br><INPUT type="file" style="width:80%" NAME="File">'; " +
        
" document.getElementById('MyFile').insertAdjacentHTML("beforeEnd",str); " +
        
" btn.value='继续添加附件'" +
       
"}"true);
        btn_AddFile.Attributes.Add(
"onClick""addFile(this)");
}
posted @ 2009-04-07 09:56  智者生存  阅读(444)  评论(0编辑  收藏  举报