Returning to same page location after executing code.

Last post 11-27-2006 6:56 PM by sbyard. 1 replies.

Sort Posts:

  • Returning to same page location after executing code.

    11-27-2006, 3:43 PM
    • Loading...
    • AustinInIL
    • Joined on 11-27-2006, 8:04 PM
    • Posts 1

    My ASPX page retrieves names from a database into a checkboxlist.  This can be a relative long list. 

    The user clicks on the associated checkbox to select some of the names, after which a button at the bottom of the page is clicked to calculate the number of selected items.  The total is then displayed following that button.

    What I want to do is return to that the same page location after the number has been calculated, but it returns to the top of the page. 

    Any suggestions?

    Here's the code:

     <br><br>  
     <a name="ChkTot"></a>
        <asp:Button id="cmdChkTot" onclick="cmdChkTot_Click" runat="server" Width="100" Text="Check Total"></asp:Button>
     <br><br>
    ..................

       dim mstrAttendTot as string = "0"
    .................. 

    Sub cmdChkTot_Click(sender as Object, e as EventArgs)
        dim PCount as integer
        dim itm
                    for each itm in chkNames.Items
                        if itm.Selected then
          PCount = PCount + 1
                        end if
                    next
        mstrAttendTot = PCount
    end sub

  • Re: Returning to same page location after executing code.

    11-27-2006, 6:56 PM
    • Loading...
    • sbyard
    • Joined on 03-25-2003, 11:42 PM
    • North Yorkshire - England
    • Posts 1,177

    For VS2005, in the page definition, add the following attribute

     <%@ Page Language="C#" MaintainScrollPositionOnPostback="true" %>

    If it was easy, everybody would be doing it.
Page 1 of 1 (2 items)
Microsoft Communities
Page view counter