Don't want to load the page everytime when I clicked on any ImageButton in DataList

Discussion in 'Software' started by tapasmahata, Jan 18, 2008.

  1. tapasmahata

    tapasmahata

    Joined:
    Jan 12, 2008
    Messages:
    7
    Location:
    Kolkata
    Hi Everybody,

    I am using a DataList in ASP.NET 1.1(C#) with some ImageButton. Images of the ImageButton binds at runtime and the DataList is binds when the page loads. I want to show a bigger view of the Image, showing in the ImageButton, in an another Image control. It displays it but everytime I click on the ImageButton the Whole page reloads again and again. So it takes a lot of time. Is there any way by which I can display image without reloading the whole page.

    Regards
    Tapas

    HTML CODE:

    <asp:datalist id="listImage" style="Z-INDEX: 101; LEFT: 440px; POSITION: absolute; TOP: 272px"
    Height="152px" Width="416px" BorderColor="SkyBlue" runat="server" RepeatColumns="3" OnItemCommand="Show"
    GridLines="Both">
    <SeparatorStyle HorizontalAlign="Center" ForeColor="Aqua" BorderStyle="Solid" VerticalAlign="Middle"
    BackColor="Fuchsia"></SeparatorStyle>
    <ItemTemplate>
    <P align="center">
    <asp:ImageButton id=myImage Width="50px" Height="50px" CommandName="ShowImage" ImageAlign="Baseline" AlternateText='<%#DataBinder.Eval(Container.DataItem,"pid") %>' Runat="server" ImageUrl='<%#DataBinder.Eval(Container.DataItem,"pid","http://mysite.com/demo/images/{0}.jpg")%>'>
    </asp:ImageButton>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:Label id="myLabel" Width="1px" Height="1px" Runat="server" Visible="False"></asp:Label>
    <asp:Button id=myHiddenBtn1 runat="server" Width="80px" Height="24px" Text='<%# DataBinder.Eval(Container.DataItem,"pname")%>' Visible="False">
    </asp:Button>
    <asp:Button id=myHiddenBtn2 runat="server" Width="80px" Height="24px" Text='<%# DataBinder.Eval(Container.DataItem,"psize")%>' Visible="False">
    </asp:Button><!%# DataBinder.Eval(Container.DataItem,"pname")%></P>
    </ItemTemplate>
    </asp:datalist>

    Code Behind :

    //These functions are only to show the image with bigger view in a Image
    //control. Please Help me....

    public void Show(Object s, DataListCommandEventArgs e)
    {

    ImageButton anImage=(ImageButton)e.Item.FindControl("myImage");
    Label anLabel=(Label)e.Item.FindControl("myLabel");
    if(anImage.CommandName=="ShowImage")
    {
    string pcode;
    //btnAddToCart.Enabled=true;
    //Label1.Text=anImage.AlternateText;
    pcode=anImage.AlternateText;
    ViewImage(pcode);


    }
    Button Btn1=(Button)e.Item.FindControl("myHiddenBtn1");
    Button Btn2=(Button)e.Item.FindControl("myHiddenBtn2");
    Label1.Text=Btn1.Text+" | "+Btn2.Text;

    }

    public void ViewImage(string sa)
    {
    //Label1.Text=sa;
    imgShow.ImageUrl="http://mysite.com/demo/images/"+sa+".jpg";
    imgShow.AlternateText=sa;

    }
     
    tapasmahata, Jan 18, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. saraswathyrajaram

    vb.net datalist problem

    saraswathyrajaram, Aug 21, 2006, in forum: Software
    Replies:
    0
    Views:
    742
    saraswathyrajaram
    Aug 21, 2006
  2. aspnetNewbie

    How do I reference a radio button in a datalist control

    aspnetNewbie, Apr 30, 2007, in forum: General Computer Support
    Replies:
    0
    Views:
    1,133
    aspnetNewbie
    Apr 30, 2007
  3. tapasmahata

    Show ImageButton of DataList as Thumbnail

    tapasmahata, Jan 15, 2008, in forum: Software
    Replies:
    0
    Views:
    1,233
    tapasmahata
    Jan 15, 2008
  4. Propp
    Replies:
    0
    Views:
    1,540
    Propp
    Jun 6, 2010
  5. subashini

    check box in datalist

    subashini, Mar 1, 2012, in forum: General Computer Support
    Replies:
    4
    Views:
    1,470
    subashini
    Mar 2, 2012
Loading...

Share This Page