1
Answer

how to store multiple images urls(getting fromdatabase) to linkbutton

 <asp:LinkButton runat="server" ID="lnkCOI"  title="View Documents"  CausesValidation="false" OnClientClick=<%# "LoadDocument('" + Eval("Documents") + "')" %>  >
                                                                             <i class="fa fa-file margin-r-5" style="color:chocolate;"></i>
                                                                        </asp:LinkButton>i taking the linkbutton like this now i want to store multiple images to a single linkbutton when click on it display all the documents in a sigle popup please give me solution

Answers (1)

1
Photo of Jithu Thomas
186 10.2k 109.1k 1y

To achieve displaying multiple images from URLs stored in a database in a single popup when a link button is clicked, you can use JavaScript to create a popup and dynamically load the images into it. Here's how you can do it:

  1. Retrieve the image URLs from the database and store them in a data structure (such as an array or list) on the server-side.
  2. Create a JavaScript function to open a popup window and display the images.
  3. Use ASP.NET to call this JavaScript function when the link button is clicked, passing the image URLs as parameters.
<asp:LinkButton runat="server" ID="lnkCOI" title="View Documents" CausesValidation="false"
    OnClientClick='<%# "return LoadDocumentsPopup([" + GetDocumentUrls(Eval("DocumentIds")) + "])" %>'>
    <i class="fa fa-file margin-r-5" style="color:chocolate;"></i> View Documents
</asp:LinkButton>

<script type="text/javascript">
    function LoadDocumentsPopup(documentUrls) {
        var popupWindow = window.open("", "DocumentsPopup", "width=600,height=400");
        popupWindow.document.write("<html><head><title>Documents</title></head><body>");
        
        // Iterate through each document URL and display it in the popup
        for (var i = 0; i < documentUrls.length; i++) {
            popupWindow.document.write("<img src='" + documentUrls[i] + "' style='display:block;margin-bottom:10px;' />");
        }

        popupWindow.document.write("</body></html>");
        popupWindow.document.close();
        return false; // Prevent the default action of the link button
    }
</script>
  • GetDocumentUrls is a server-side method that retrieves document URLs from the database and formats them as a JavaScript array.
  • LoadDocumentsPopup is a JavaScript function that creates a popup window and writes HTML to display the images.
  • When the link button is clicked, LoadDocumentsPopup function is called with the array of document URLs as a parameter.

Make sure to replace GetDocumentUrls with your server-side method that retrieves document URLs from the database. Also, ensure that the URLs retrieved from the database are properly formatted and accessible.