2011-07-14 76 views
9

嗨,你們都在這個項目上爲學校工作,有問題保持頁面位置上回發

<asp:LinkButton ID="LinkEdit" runat="server" CssClass="right_bottom" 
     onclick="LinkEdit_Click" Height="16px">edit</asp:LinkButton> 
    <asp:LinkButton ID="Linkhide" runat="server" CssClass="right_bottom" 
     onclick="Linkhide_Click" Visible="False" hide</asp:LinkButton> 
    <br /> 
    <hr style="width: 740px; height: -6px; margin-left: 0px; " /> 
    <asp:Label ID="labelFullname" runat="server" Text="Full Name" CssClass="left_top"></asp:Label> 
    <asp:Label ID="labelNameDisplay" runat="server" Text="Put name here" CssClass="right_top"></asp:Label> 

    <br /> 
    <asp:Panel ID="panelName" runat="server" Height="240px" Visible="False" CssClass="panel_top" 
     style="text-align: left;"> 

     <asp:Label ID="Label8" runat="server" CssClass="left" Text="Please allow 24 hours for name changes to take effect."></asp:Label> 
    <div align="center"><br /> 
    <br /> 
    <table> 
     <tr> 
     <td class="label_new"> 
     <asp:Label ID="Label4" runat="server" Text="Full Name:" ToolTip="Name Displayed"></asp:Label> 
     </td> 
     <td align="left"> 

      <asp:DropDownList ID="DropDownList1" runat="server" BorderStyle="Groove" 
       Font-Names="Segoe UI,Tahoma,Verdana,Arial,Times" Font-Size="100%" Height="25px" 
      valign="middle" Width="250px"> 
       <asp:ListItem></asp:ListItem> 
       <asp:ListItem></asp:ListItem> 
       <asp:ListItem></asp:ListItem> 
      </asp:DropDownList> 
     </td> 
    </tr> 


    <tr> 
     <td class="label_new"> 
     <asp:Label ID="Label2" runat="server" Text="First Name:"></asp:Label> 
     </td> 
     <td align="left"> 
     <asp:TextBox ID="txtFirstName" runat="server" BorderStyle="Groove" Font-Names="Segoe UI,Tahoma,Verdana,Arial,Times" Font-Size="100%" Height="20px" 
      valign="middle" Width="242px"></asp:TextBox> 
     </td> 
    </tr> 

    <tr> 
     <td class="label_new"> 
     <asp:Label ID="Label9" runat="server" Text="Middle Name:"></asp:Label> 
     </td> 
     <td align="left"> 
     <asp:TextBox ID="txtMiddleName" runat="server" BorderStyle="Groove" Font-Names="Segoe UI,Tahoma,Verdana,Arial,Times" Font-Size="100%" Height="20px" 
      valign="middle" Width="242px" onfocus="if (this.value == 'optional') { this.value=''; this.style.color='black';}" /> 
     </td> 
    </tr> 

    <tr> 
     <td class="label_new"> 
     <asp:Label ID="Label10" runat="server" Text="Last Name:"></asp:Label> 
     </td> 
     <td align="left"> 
     <asp:TextBox ID="txtLastName" runat="server" BorderStyle="Groove" Font-Names="Segoe UI,Tahoma,Verdana,Arial,Times" Font-Size="100%" Height="20px" 
      valign="middle" Width="242px"></asp:TextBox> 
     </td> 
    </tr> 
    <tr> 
    <td colspan="2"> 
     <asp:Button ID="btnSaveChanges" runat="server" Text="Save Changes" 
      onclick="btnSaveChanges_Click" /> 
    </td> 
    </tr> 
    </table> 
    </div> 

    </asp:Panel> 

我有4塊板以這種形式就像在Facebook帳戶設置。 我在這裏的問題是,當我顯示面板它只是跳轉到頁面的頂部。

想做就像facebook一樣。點擊並點擊您點擊的位置。

謝謝

+0

如果我理解正確的話,就可以直接使用HTTP://www.asp。 net/ajax/ajaxcontroltoolkit/Samples/Accordion/Accordion.aspx – Mediator

+0

你爲什麼發送這麼長的標記?你可以更簡潔。 :) –

+0

@mike gee。請記住標記答案,因爲它解決了您的問題。謝謝。 –

回答

1

我不完全確定你在問什麼。 Facebook使用了很多ajax樣式的回調,這意味着該頁面不會使用asp .net樣式的回傳來重新加載。如果你剛開始,我建議你嘗試將代碼放入Ajax .Net UpdatePanel,同時學習Ajax/JSON/XMLHttpRequest等的詳細信息。

如果您只是想確保瀏覽器窗口在回發後保持在相同的滾動條位置,然後將頁面設置爲使用MaintainScrollPositionOnPostback =「true」指令。

26

您可以設置MaintainScrollPositionOnPostback屬性頁面上:

Page.MaintainScrollPositionOnPostback = true; 

或把它放在網頁聲明

<%@ Page MaintainScrollPositionOnPostback="true" %> 
+1

工作感謝傢伙Page.MaintainScrollPositionOnPostback = true; –

相關問題