ASP.NET implement anchor without postback

2019-08-09 08:32发布

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?

2条回答
对你真心纯属浪费
2楼-- · 2019-08-09 08:51

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
查看更多
来,给爷笑一个
3楼-- · 2019-08-09 09:00

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.

查看更多
登录 后发表回答