Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 24th, 2008, 01:06 AM
Authorized User
 
Join Date: Mar 2008
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Replace image

I am working on asp page.
User requirement is he want to show reocrds in Tree Structure.
For E.g
He needs the summary details of the total sales order.
He don't want to view each and every transaction.
This he needs on demand. i.e
I am showing monthly total sales and beside this i have place an Plus sign image.
so now when user will click on this image it has to get replaced by minus sign image and corresponding transaction records should get displayed.

How should i implement this?

Thanks in advance.


987654321
__________________
987654321
 
Old March 24th, 2008, 12:23 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Here is one way to do what I think you're trying to do. You put a repeater within a repeater to get the child objects within a DIV layer. The + image has an onclick event that uses the javascript function below to change the class of the DIV layer which will show the contents of the DIV layer and replaces the image + image with a - image. Its pretty straight forward.

<asp:Repeater ID="rptArea" Runat="server">
    <ItemTemplate>
        <img border="0" width="16" height="16" src="/images/icons/max_sm.gif" align="absmiddle" name="_Area<%#DataBinder.Eval(Container.DataItem, "AreaID")%>" alt="Maximize" onclick="javascript:showHide('Area<%#DataBinder.Ev al(Container.DataItem, "AreaID")%>');" />
        <%#DataBinder.Eval(Container.DataItem, "AreaName")%><br />
        <div id="Area<%#DataBinder.Eval(Container.DataItem, "AreaID")%>" class="<% Response.Write(_ShowHide) %>">
            <asp:Repeater ID="rptSubarea" Runat="server">
                <ItemTemplate>
                    <img border="0" src="/images/spacer.gif" width="16" height="0" align="absmiddle" />
                    <img border="0" src="/images/icons/max_sm.gif" width="16" height="16" align="absmiddle" name="_Sub<%#DataBinder.Eval(Container.DataItem, "SubID")%>" alt="Maximize" onclick="javascript:showHide('Sub<%#DataBinder.Eva l(Container.DataItem, "SubID")%>');" />
                    <%#DataBinder.Eval(Container.DataItem, "SubName")%><br />
                </ItemTemplate>
            </asp:Repeater>
        </div>
    </ItemTemplate>
</asp:Repeater>

function showHide(div)
{
    var obj = document.getElementById(div).style;
    obj.display = obj.display != 'block' ? 'block' : 'none';
    if(document['_'+div].alt == "Maximize")
    {
        document['_'+div].src = "/images/icons/min_sm.gif";
        document['_'+div].alt = "Minimize";
    }
    else
    {
        document['_'+div].src = "/images/icons/max_sm.gif";
        document['_'+div].alt = "Maximize";
    }
}

 
Old March 26th, 2008, 06:12 AM
Authorized User
 
Join Date: Mar 2008
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you.
I will implement this code and get back to forum.



987654321
 
Old March 26th, 2008, 07:57 AM
Authorized User
 
Join Date: Mar 2008
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

repeater is the ASP.net control.Is'nt it?
I am purely working on simple asp page. while impletmenting the given code it was telling me to save file with aspx extension. Then further how to travel ???????????? How should i do this?


987654321





Similar Threads
Thread Thread Starter Forum Replies Last Post
Upload image-create & save thumbnail-display image angshujit ASP.NET 2.0 Professional 6 July 11th, 2013 10:34 PM
Copy kodak image edit control's image to clipboard vishwanathduddilla Visual Studio 2005 0 November 3rd, 2008 10:10 AM
set image on <asp:Image> stored in DataBase myself.panku ASP.NET 2.0 Professional 1 August 11th, 2008 10:41 AM
How to replace " TheBeerHouse " banner image? irisl BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 April 2nd, 2008 08:59 PM
How to replace image in asp?? Swati Chari Classic ASP Basics 1 March 27th, 2008 07:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.