本文介绍了如何在点击链接按钮时看到下一个文件上载控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在开发基于票据提交的项目,其中包含带有C#代码的submit_ticket.aspx页面和sql server 2008 r2数据库!

对于这个我已经采取了5个文件上传控件,一个链接按钮有id = lnkaddmore!

默认情况下第一个文件上传控件可见,其余部分不可见!

我想显示添加下一个文件上传控件应该在点击lnkaddmore时可见但以前不应该回发!

我尝试了很多!

但我没有没有成功!

有人帮帮我吗?

提前致谢!

Hi to all,
I am working on project which has based as ticket submitting which having "submit_ticket.aspx" page with C# code behind and sql server 2008 r2 database!
For this i have taken 5 file upload controls and one link button has "id=lnkaddmore" !
The first file upload control has visible by default and remaining aren't visible !
I wanna to show adding next file upload control should visible on click of lnkaddmore but previous shouldn't postback !
I tried lots !
but I didn't get success yet !
Anybody Help Me Please ?
Thanks in advance !

推荐答案

<div id="divFile">
    <div>
        <asp:FileUpload ID="FileUpload1" runat="server" Style="width: 200px;" />
        <asp:LinkButton ID="lnkAddFiles" runat="server" OnClientClick="return AddFile()">Add</asp:LinkButton>
    </div>
</div>










<script type="text/javascript">
       var i = 1;
       function AddFile() {
           i++;
           var div = document.createElement('DIV');
           div.innerHTML = '<input id="file' + i + '" name="file' + i + '" type="file" style="margin-bottom:10px;width:200px;" /><a href="#" style="font-weight:bold; margin-left:10px;" onclick="return RemoveFile(this)">Remove</a>';
           document.getElementById("divFile").appendChild(div);
           return false;
       }
       function RemoveFile(file) {
           document.getElementById("divFile").removeChild(file.parentNode);
           return false;
       }
   </script>







使用以上设计和javascript。它可能会使用全部。




Use the above design and javascript. it may use full to you.


这篇关于如何在点击链接按钮时看到下一个文件上载控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 05:11