Avatar of williecg
williecg
Flag 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
ASPASP.NETVB ScriptMobileDesktops

Avatar of undefined
Last Comment
Zvonko

8/22/2022 - Mon
Zvonko

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>

Zvonko

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>

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
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Zvonko

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()





williecg

ASKER
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
Zvonko

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Zvonko

Remove the blank char after < char.

There is a problem with the EE code snippet editor.



⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
williecg

ASKER
thanks fo much, works great.

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

thanks again

WillieCg
Zvonko

You are welcome  :  )