We help IT Professionals succeed at work.

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
Comment
Watch Question

ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006

Commented:

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>

ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006

Commented:

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>

Author

Commented:
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
ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006

Commented:

For the Anchor tags was this my VB code:

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


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





Author

Commented:
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
Systems architect
CERTIFIED EXPERT
Top Expert 2006
Commented:

This is you jump code:

Response.Write("< script>location.hash='second'< /script>")
ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006

Commented:

Remove the blank char after < char.

There is a problem with the EE code snippet editor.



Author

Commented:
thanks fo much, works great.

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

thanks again

WillieCg
ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006

Commented:

You are welcome  :  )

Explore More ContentExplore courses, solutions, and other research materials related to this topic.