Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update panel asp.net - page refresh

Page url: http://advancedmedia.co.il/data.aspx

Code:

<asp:Content ID="Content2" ContentPlaceHolderID="page_content_cp" Runat="Server">
<asp:UpdatePanel runat="server" ID="UP1" UpdateMode="Conditional">
<ContentTemplate>
<section id="page_section">
<div class="data_top">
<ul class="bxslider">
    <asp:ListView ID="LV_slider" runat="server" DataSourceID="**">
    <ItemTemplate>
    <li>
    <asp:Image ID="Image11" ImageUrl='<%#XPath("big_image_url") %>' AlternateText="slider"  runat="server"  />
    </li>
    </ItemTemplate>
    </asp:ListView>

</ul>
</div>
<div class="shaddow"></div>
<div class="data_bottom">
<asp:ListView runat="server" ID="LV_data_bottom" DataSourceID="**">

<ItemTemplate>
<div style="display:inline;">
<asp:LinkButton runat="server" CommandArgument='<%#XPath("big_image_url") %>' ID="LB_thumb" OnClick="lb_thumb1" ><asp:Image runat="server" ID="IMG_img1" ImageUrl='<%#XPath("small_image_url") %>' />
<asp:Label runat="server" CssClass="title" ID="bottom_label" Text='<%#XPath("title") %>'></asp:Label></asp:LinkButton>
</div>


</ItemTemplate>
</asp:ListView>
</div>


</section>
</ContentTemplate>
</asp:UpdatePanel>

        <asp:XmlDataSource ID="**" runat="server" 
            DataFile="~/***/***" XPath="/Data/**/**">
        </asp:XmlDataSource> 
</asp:Content>

Click on the thumbs "jump" the page.

I dont want the page will "jump"/"refresh" after click on thumb. how can i do that? Maybe i wrong on the place of the updatepanel ?

like image 216
Oshrib Avatar asked Feb 11 '14 14:02

Oshrib


People also ask

How to refresh Update Panel in ASP net?

Now to refresh the UpdatePanel using JavaScript, you just need to access the Button and call its Click function. This way the Button's OnClick event handler on server side is invoked and the Label displays the current time. Another way is to make use of the __doPostBack JavaScript method of ASP.Net.

How Update Panel works in ASP net?

Introduction. UpdatePanel controls are a central part of AJAX functionality in ASP.NET. They are used with the ScriptManager control to enable partial-page rendering. Partial-page rendering reduces the need for synchronous postbacks and complete page updates when only part of the page has to be updated.

How do I update UpdatePanel?

If you plan to use the Update method, set the UpdateMode property to Conditional. If you want the decision to update the panel in server logic, ensure that the ChildrenAsTriggers property is false and that no explicit triggers are defined for the panel.


2 Answers

You can always get it done using updatepanel and microsoft ajax... but there is a better and more lightweight alternative. Use jquery to swap the main image on top when the thumbnails are clicked, without doing a page refresh.

Define a surrounding div for the imain image with id "imageBox"

<a href="#" id="changeImage" rel="1"><img class="thumb" src="image1_thumb.jpg" /></a>
<div id="imageBox">&nbsp;</div>

then,

$(document).ready(function(){
    $('#changeImage').click(function(){
        var rel = $(this).attr('rel');
        $("#imageBox").html("<img src='image" + rel + ".jpg' />");
    })
}); 

This is both clean and lightweight. no Microsoft ajax panel junk.

like image 159
Aby Avatar answered Sep 20 '22 20:09

Aby


I'm not sure about what is your problem here, but if you want to separate the Update Panel into two you can do so.

There's an explanation on how different update panels can trigger themselves. http://www.asp.net/web-forms/tutorials/aspnet-ajax/understanding-asp-net-ajax-updatepanel-triggers

like image 32
boonboon Avatar answered Sep 20 '22 20:09

boonboon