2014-02-11 164 views
6

頁網址:http://advancedmedia.co.il/data.aspx更新面板asp.net - 刷新頁面

代碼:

<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> 

點擊大拇指 「跳」 的頁面。

我不想讓頁面在點擊拇指後「跳轉」/「刷新」。我怎樣才能做到這一點?也許我錯了在updatepanel的地方?

+0

什麼是你的問題的背後? – Christos

+0

和...你的**問題**? – Sachin

+0

編輯的問題 – Oshrib

回答

6

你總是可以使用updatepanel和microsoft ajax完成它...但是有一個更好,更輕量級的選擇。使用jquery在單擊縮略圖時將主圖像置於頂部,而不進行頁面刷新。

定義周圍DIV ID爲 「imageBox」 的IMAIN圖像

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

然後,

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

這是既乾淨又輕巧。沒有微軟ajax面板垃圾。

+0

真棒!工作像一個魅力 – Oshrib

+0

或不:( http://advancedmedia.co.il/data.aspx 也許它不工作與linkbutton? – Oshrib

+0

@Bside,它應該與任何按鈕,你將不得不刪除eyour asp。淨按鈕代碼與純HTML的img和<我的帖子中顯示的標籤。讓我知道如果它仍然不會工作。 – Aby

0

在LinkBut​​ton上設置ClientIDMode = Auto。

1

在列表視圖頁面中使用AutoPostBack="false"不能刷新..或者使用JavaScript來改變圖像

1

ScriptManager

<asp:ScriptManager EnablePartialRendering="true" 
ID="ScriptManager1" runat="server"></asp:ScriptManager> 
<asp:Content ID="Content2" ContentPlaceHolderID="page_content_cp" Runat="Server"> 
<asp:UpdatePanel runat="server" ID="UP1" UpdateMode="Conditional"> 
    <!-- bla bla bla.. --> 
1

你嘗試更改以下

UpdateMode="Conditional" 

有了這個?

UpdateMode="Always" 
0

一切似乎都正確。 以下是更新面板的示例。

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication3.WebForm1" %> 

<!DOCTYPE html> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
</head> 

<body> 
    <form id="form1" runat="server"> 
     <div> 
     <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 

     <asp:UpdatePanel ID="Updatepanel1" runat="server" UpdateMode="Conditional"> 
      <ContentTemplate> 
       <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> 
       <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 
       <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton> 
      </ContentTemplate> 
     </asp:UpdatePanel> 
    </div> 
</form> 

代碼

namespace WebApplication3 
{ 
    public partial class WebForm1 : System.Web.UI.Page 
    { 
     protected void Page_Load(object sender, EventArgs e) 
     { 

     } 

     protected void Button1_Click(object sender, EventArgs e) 
     { 
      this.Label1.Text = "change Test 1"; 
     } 

     protected void LinkButton1_Click(object sender, EventArgs e) 
     { 
      this.Label1.Text = "change Test 2"; 
     } 
    } 
}