Link to home
Start Free TrialLog in
Avatar of williecg
williecgFlag for United States of America

asked on

Jump to sections of an asp net page

Hello,
I have an asp net page with separate VB code behind page.
The aspx page is about 2000 px long. There are is a top, middle, and lower sections.
I need to be able to jump to each section based on various events in my code behind.
I was thinking of putting a heading label for each section.  I would like a command that I could insert as needed in my code behind to jump to specific labels. It will need to work across desktop and mobile platforms.
Thanks,
WillieCg
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Jump to anchor name:


<%@ Page Title="My Page" Language="VB"  %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
</head>
<body>
<a name="first"></a>
<div style="height:600px">First</div>
<a name="second"></a>
<div style="height:600px">Second</div>
<a name="third"></a>
<div style="height:600px">Third</div>
<% If (10 > 0) Then %>
<script>location.hash="second";</script>
<% End If %>
</body>
</html>

Or by JavaScript:


<%@ Page Title="My Page" Language="VB"  %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
</head>
<body>
<div id="first"  style="height:600px">First</div>
<div id="second" style="height:600px">Second</div>
<div id="third" style="height:600px">Third</div>
<script>
setTimeout('document.getElementById("<% If (10 > 0) Then Response.Write("second") %>").scrollIntoView(true)',0);
</script>
</body>
</html>

Avatar of williecg

ASKER

Hello,
Thanks for the info.

I understand
<a name="first"></a>

is the tag in the aspx page.

What is the vb command in the code behind page?

Thanks,

WCGee

For the Anchor tags was this my VB code:

<% If (10 > 0) Then %>
<script>location.hash="second";</script>
<% End If %>

Open in new window


But you can do it also like the second example with VB statement: Response.Write()





Thanks, I am a tinker tinkerer. I do not follow your point.

I have a button in the aspx file named button_jump_2_top.

Here is the code in the code behind file:

   Protected Sub Button_Jump_2_top_Click(sender As Object, e As EventArgs) Handles Button_Jump_2_top.Click

       'What goes here?

    End Sub

What is the code that jumps to <a name="top"></a> in the aspx file.

Thank for your patience.

WillieCg
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

Remove the blank char after < char.

There is a problem with the EE code snippet editor.



thanks fo much, works great.

also name is an outdated tag, I changed it to id in the aspx page.

thanks again

WillieCg

You are welcome  :  )