停止回发一个菜单项点击,但该事件应该执行 [英] Stop PostBack in a MenuItem click but the event should execute
问题描述
在我的网站,我加了菜单
控制和当一个菜单项
单击该数据加载到 GridView控件
但重新加载页面再次谈到顶部。当我点击菜单项
中的数据应该加载,也是网页不应该刷新(即页面不应该做一个回传
同时在数据加载一个 GridView控件
)
In my website I added menu
control and when one MenuItem
is clicked the data loads to the GridView
but the page reloads again and it comes to top. When I click on MenuItem
the data should load and also the page should not refresh.(i.e the page should not do a PostBack
while the data loads in a GridView
)
<asp:Menu ID="Menu1" OnMenuItemClick="Menu1_MenuItemClick" CssClass="portfolio-item" EnableViewState="true" runat="server" Orientation="Horizontal" >
<Items>
<asp:MenuItem Text="Items" Value="Items" Selectable="false" >
<asp:MenuItem Text="item1" Value="item1" Selectable="false" >
<asp:MenuItem Text="item2" Value="item2" ></asp:MenuItem>
<asp:MenuItem Text="item3 Value="item3" ></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem Text="qwerty" Value="qwerty" Selectable="false">
<asp:MenuItem Text="MenuSub" Value="MenuSub"></asp:MenuItem>
</asp:MenuItem>
</asp:MenuItem>
</Items>
</asp:Menu>
它不应该刷新的时候数据加载在菜单项
点击
It should not refresh when the data loads in a MenuItem
click.
推荐答案
您可以设置的 MaintainScrollPositionOnPostback
以真
以防止页面出现顶部和回发
筛选后,退还用户在客户端浏览器的同一位置:
You can set the MaintainScrollPositionOnPostback
to True
to prevent your page comes to top and return the user to the same position in the client browser after postback
. Like this:
<%@ Page Title="" Language="C#" MaintainScrollPositionOnPostback="True" ... %>
这篇关于停止回发一个菜单项点击,但该事件应该执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!