开发者

ASP.net Listview AJAX ModalPopupExtender

开发者 https://www.devze.com 2023-03-30 07:54 出处:网络
I am trying to get a modalpopupextender to show from a listview that is inside of a tab panel. If this is possible can someone please help me? This is my image listview, from here I would just like to

I am trying to get a modalpopupextender to show from a listview that is inside of a tab panel. If this is possible can someone please help me? This is my image listview, from here I would just like to pop up images - like with lightbox or fancybox. I would really like to use the ajax modal though, because other parts of this page are using it and I would like the pages modals to be consistent.

<!-- Images -->
<asp:TabPanel id="tab5" runat="server" HeaderText="Images">
    <ContentTemplate>
        <ul class="info">
        <asp:ListView ID="lvImages" runat="server" DataSourceID="dsMarketingImages">
        <ItemTemplate> 
            <li title='<%# eval("MarketingData") %>'>
                <a target="_blank" href="<%# eval("MarketingData") %>"><%#Eval("MarketingTitle")%></a>
            </li>
        </ItemTemplate>
        </asp:ListView>
        </ul>
    </ContentTemplate>        
</asp:TabPanel>

I am trying this but get the error: The server tag is not well formed. How do I display the image inside of the modal? I'm pretty stumped here. Help would be ap开发者_JAVA百科preciated!

        <asp:ListView ID="lvImages" runat="server" DataSourceID="dsMarketingImages" DataKeyNames="MarketingID">
        <ItemTemplate>
            <li>
                <asp:LinkButton ID="ViewImagesButton" runat="server"><%#Eval("MarketingTitle")%></asp:LinkButton><asp:ImageButton ID="ImageButton1" runat="server" Style="float:right;" AlternateText="" ImageUrl="../../images/delete.png" CommandName="Delete" OnClientClick="return confirm('Are you sure you want to delete this image?')" />
                <asp:Panel ID="ViewImagesPanel" runat="server">
                    <asp:Image ID="Image1" runat="server" href="<%# Eval("MarketingData") %>"/>
                </asp:Panel>
                <asp:ModalPopupExtender ID="ViewImagesModal" runat="server" BackgroundCssClass="modalBackground" DropShadow="true" DynamicServicePath="" Enabled="true" PopupControlID="ViewImagesPanel" TargetControlID="ViewImagesButton"></asp:ModalPopupExtender>
            </li>
        </ItemTemplate>
        </asp:ListView> 


Why not make the ListItem a LinkButton and programmatically show the Popup?


I found a tutorial on making a picture album using a listview that helped me answer my own question! http://www.dotnetcurry.com/ShowArticle.aspx?ID=175 is where you will find it. I hope this post will help someone in the future. Here is the code I have now that works. My server tag error was because I used "" instead of '' around the <% %> which apparently is a no no. :O)

<!-- Images -->
<asp:TabPanel id="tab5" runat="server" HeaderText="Images">
<HeaderTemplate>Images</HeaderTemplate>
    <ContentTemplate>
        <ul class="info">
        <asp:ListView ID="lvImages" runat="server" DataSourceID="dsMarketingImages" DataKeyNames="MarketingID">
        <ItemTemplate>
            <li>
                <asp:LinkButton ID="ViewImagesButton" runat="server"><%#Eval("MarketingTitle")%></asp:LinkButton><asp:ImageButton ID="ImageButton1" runat="server" Style="float:right;" AlternateText="" ImageUrl="../../images/delete.png" CommandName="Delete" OnClientClick="return confirm('Are you sure you want to delete this image?')" />
                <asp:Panel ID="ViewImagesPanel" runat="server">
                    <asp:Image ID="Image1" runat="server" AlternateText='<%#Eval("MarketingTitle")%>' ImageUrl='<%# Eval("MarketingData") %>'/>
                </asp:Panel>
                <asp:ModalPopupExtender ID="ViewImagesModal" runat="server" BackgroundCssClass="modalBackground" DropShadow="true" DynamicServicePath="" Enabled="true" PopupControlID="ViewImagesPanel" TargetControlID="ViewImagesButton"></asp:ModalPopupExtender>
            </li>
        </ItemTemplate>
        </asp:ListView>  
        </ul>
    </ContentTemplate>     
</asp:TabPanel>
0

精彩评论

暂无评论...
验证码 换一张
取 消