Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to maintain scroll position across postback

Status
Not open for further replies.

ASPnetNovice

Programmer
Apr 28, 2005
19
US
Hello,

I need to know how to link to a given section of the page using asp .net

I have a page with a button , every time the button is click a new block of controls is added to the page.

As a result the lengh of the page increases and every time time a postback occur the page is display from the top and I need to scroll down to see my latest added block. (maintain scroll position)

That is uncorftable for a user .

I use SmartNavigation="true" on the page directive and it partially solve the problem

what I really want to do is scroll to the bottom of the page every time that the page is loaded.

I am using this but it doesn't work

<a name=bottom></a>
and access that with
sub pageLoad(.....)
response.Redirect("myurl#bottom")
end sub

will appreciate any help

thanks.
 
sub pageLoad(.....)
response.Redirect("myurl#bottom")
end sub
If you do that on Page Load it will simply re-direct back to itself and end up in an infinate loop.

You need to redirect on the button click, after you have added all of you other controls.

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
If you have a Control (textbox or sumpin), set the focus to that control...This will kick off whenever you tell it to at any postback. Turn that smart nav OFF!! Itll cause you more grief than good
Code:
        Sub Page_Load()
              If Not Page.IsPostBack Then
                    BindYourStuff()
              End If
        End Sub

        Sub ActionDooHickey(sender as object,e as eventargs)
              'My Actions
              SetFocus(myASPNetTextBoxName)
        End Sub

	Private Sub SetFocus(ByVal ctrl As Control)
        ' Define the JavaScript function for the specified control.
    	Dim focusScript As String = "<script language='javascript'>" & _
      	"document.getElementById('" + ctrl.ClientID & _
      	"').focus();</script>"

        ' Add the JavaScript code to the page.
    	Page.RegisterStartupScript("FocusScript", focusScript)
	End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top