大家都知道如何使用UpdatePanel,這邊就不贅述

某些情況之下可能需要動態產生非常多的Button及其事件

文章標籤

Chien-Ching 發表在 痞客邦 留言(0) 人氣()

在一般的asp.net網站

要如何讓網頁在不postback的情況中改變顯示資料呢?

文章標籤

Chien-Ching 發表在 痞客邦 留言(0) 人氣()

前端:

<script type="text/javascript">
  window.onload = function (){var h = document.getElementById("<%=hfScrollPosition.ClientID%>");
               document.getElementById("<%=scrollArea.ClientID%>").scrollTop = h.value;}
   function SetDivPosition(){var intY = document.getElementById("<%=scrollArea.ClientID%>").scrollTop;var h = document.getElementById("<%=hfScrollPosition.ClientID%>");
           h.value = intY;}

  function afterpostback(){var h = document.getElementById("<%=hfScrollPosition.ClientID%>");
            document.getElementById("<%=scrollArea.ClientID%>").scrollTop = h.value;}</script><asp:HiddenField ID="hfScrollPosition" runat="server"Value="0"/><div id="scrollArea" onscroll="SetDivPosition()"   runat="server"  style="height:225px;overflow:auto;overflow-x:hidden;">

後端:

Chien-Ching 發表在 痞客邦 留言(0) 人氣()