简体   繁体   中英

ASP.NET implement anchor without postback

I'm working on an ASP.NET web app in VS2010,C#, I want to make something like this page:

http://www.just-eat.co.uk/restaurants-simplyscrumptious/menu

when you click on food categories on left, page jumps to that category without any postback, how can I achieve it?

How to move with out post back

You use the anchor # at the end of the same page url following with the name that you with to move.

Then inside the page you place an anhro with the name that you wish to jump like

<a name="MovePosition"></a>

So if you make a link like http://www.site.com/catalog.aspx#MovePosition the browser will brink the line with the <a name="MovePosition"></a> on top.

reference: http://www.w3.org/MarkUp/1995-archive/Elements/A.html

categories menu always on the same point

If you also notice the categories on the left are stay on the same position. This can be done by many ways. In this specific page is use a script to change his location. How ever the better is to place the categories inside a div and give on this div this extra style position:fixed;bottom:0px; and will stick on the position that you have place it relative to his parent div.

There are many ways to keep the category menu stay on the same point. One other can be found here : http://www.dynamicdrive.com/dynamicindex1/staticmenu.htm even so is old code.

Just addition to the previous answer @Aristos

If on the same page, just do

<a href="#section1">Go to section 1</a>

If on another page then do

<a href="mypage.aspx#section1">Go to section 1 on another page</a>

Then define the sections with <a name="#sectionName"></a>

<a name="section1"></a>
Thi section 1
content for section 1 follows


<a name="section2"></a>
This section 2
content for section 2 follows

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM