Howto Scroll to bottom of webform - after button click ??

Hi folks,

I have a webform (vb.net), with a button at the bottom, once the user click the button I want to verify his/her input and print our his/her selection at the bottom and then change the button from verify to submit...

Everything is working fine... , except for the "auto scroll to the bottom" part... so I do a postback currently on the button click and verify a few things server side... however when it comes back I want to scroll to the bottom of my webform...

How would I do this?
Thanks!
LVL 1
newbreedccAsked:
Who is Participating?
 
raterusCommented:
untested, but should work,
Page.RegisterStartupScript("MyScrollingStuff", "<script language='javascript'>document.getElementById('" & myControl.ClientID & "').scrollIntoView();</script>")

replace "myControl" with a reference to whatever asp.net control you want to scroll to when the page loads.
0
 
Raju SrivatsavayeSoftware EngineerCommented:
I have a javascript that might work just fine for you:Here it is:

function scroll()
    {
      var coll = document.all.tags("P")
   
   
           
      coll(id).scrollIntoView(true)
      col1(id).bAlignTop = false----Here try using .bAlignBottom=true
 
   }

Just enter the id here and call this in the button click: You should be calling this javascript this way:

 Dim strScript As String = "<script language=JavaScript>"
                strScript += "Scroll();"
                strScript += "</script>"
                If (Not Page.ClientScript.IsStartupScriptRegistered("clientScript")) Then
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "clientScript", strScript)
                End If
0
 
Raju SrivatsavayeSoftware EngineerCommented:
Hey modify the javascript like this:

var coll=document.getelementbyid("button1")

tehn
coll(.scrollIntoView(true)
      coli.bAlignBottom = true
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
newbreedccAuthor Commented:
Okay tried it... I'm having problems with your :  "Page.ClientScript" it's a member of what ???
I'm using .net framework 1.1

Do I need to "Imports" anything first ?
0
 
Raju SrivatsavayeSoftware EngineerCommented:
thats for asp.net 2.0
0
 
Raju SrivatsavayeSoftware EngineerCommented:
try removing the ClientScript
0
 
newbreedccAuthor Commented:
Nope, still not working... thanks for trying anyway
0
 
Raju SrivatsavayeSoftware EngineerCommented:
try this for last time:

If (Not Page.ClientScript.IsStartupScriptRegistered("clientScript")) Then
                    Page.ClientScript.RegisterStartupScript("clientScript", strScript)
                End If
0
 
Raju SrivatsavayeSoftware EngineerCommented:
I mean this

If (Not Page.IsStartupScriptRegistered("clientScript")) Then
                    Page.RegisterStartupScript( "clientScript", strScript)
                End If
0
 
newbreedccAuthor Commented:
Still don't get it working...

By the way I changed your js function to this:

            function scroll() {
                  var coll=document.getelementbyid("btnSubmit");
                       
                  coll.scrollIntoView(true);
                                  coll.bAlignBottom = true;
            }
0
 
Raju SrivatsavayeSoftware EngineerCommented:
Lets try our javascript lil differently

 function scroll()
    {
      var coll = document.all.tags("asp")
   
   
         
      coll(btnSubmit).scrollIntoView(true)
      coll(btnSubmit).bAlignToBottom = true
 
   }
0
 
newbreedccAuthor Commented:
Dude, are you just randomly guessing or are you actually trying to help ??

It's still not working.. thanks for trying

:)
0
 
Raju SrivatsavayeSoftware EngineerCommented:
Thats a good question...I actually did this for navigating to a particular text on the page.its working well for me
0
 
raterusCommented:
Do you absolutely need to scroll to the bottom, or would scrolling to a particular control on the page suffice?
0
 
newbreedccAuthor Commented:
A particular control would be good enough..

Thanks
0
 
newbreedccAuthor Commented:
awesome raterus! thanks..
0
 
newbreedccAuthor Commented:
I simply used :

If IsPostBack Then
            Page.RegisterStartupScript("MyScrollingStuff", "<script language='javascript'>document.getElementById('" & btnSubmit.ClientID & "').scrollIntoView();</script>")
End If
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.