ASP.NET implement anchor without postback

走远了吗. 提交于 2019-12-11 12:49:13

问题


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?


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/11313592/asp-net-implement-anchor-without-postback

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!