Click here to Skip to main content
15,883,847 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 !
Posted
Comments
Ganesh KP 19-Apr-14 6:12am    
I think because of postback the page is getting refreshed and set the state of a page to the initial first time load. So, can u please post the code of where you are trying to do set the visibility of the control.
Ganesh KP 19-Apr-14 6:12am    
Try these links also

http://stackoverflow.com/questions/9360791/visible-property-of-asp-net-control-not-working

http://stackoverflow.com/questions/11309171/asp-net-update-panels-and-postback
ZurdoDev 19-Apr-14 8:22am    
FileUpload does an ajax postback I believe so if you are setting visible in C# it won't work without a full postback.

1 solution

XML
<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>



XML
<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>



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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900