ASP.NET AJAX的UpdatePanel问题 [英] ASP.NET AJAX UpdatePanel problem

查看:116
本文介绍了ASP.NET AJAX的UpdatePanel问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会试着简洁:

1) I have a dropdownlist with Autopostback set to TRUE
2) I have an UpdatePanel that contains a Label.
3) When the downdownlist selection is changed, I want to update the label.

问题:焦点失去在DropDownList中,强迫用户点击DropDownList的重置焦点回到控制

Problem: Focus is lost on the dropdownlist, forcing the user to click on the dropdownlist to reset focus back to the control.

我的解决方案:在DropDownList_SelectionChanged情况下,设置焦点回到下拉列表:

My "solution": In the DropDownList_SelectionChanged event, set focus back to the drop down list:

dropdownlist1.focus()

dropdownlist1.focus()

问题:

虽然这个伟大工程在IE,Firefox和Chrome更改滚动位置,使得其被分配焦点的控件位于浏览器窗口的可见部分的底部。这通常是一个非常迷惑副作用

While this works great in IE, Firefox and Chrome change the scroll position such that the control which was assigned focus is positioned at the bottom on the visible portion of the browser window. This is often a very disorientating side effect.

这怎么能避免因此它可以在FF,因为它在IE浏览器?

How can this be avoided so it works in FF as it does in IE?

推荐答案

尝试 MaintainScrollPositionOnPostback 在这3种方式之一

  • 在编程 - Page.MaintainScrollPositionOnPostBack = TRUE;
  • 页声明 - <%@页MaintainScrollPositionOnPostback =真正的%>
  • 在web.config中 - <网页maintainScrollPositionOnPostBack =真/>

您可能还需要在ScriptManager的声明后添加此javascript:

You may also need to add this javascript after the scriptmanager declaration:

<script type="text/javascript">

var prm = Sys.WebForms.PageRequestManager.getInstance();

prm.add_beginRequest(beginRequest);

function beginRequest()
{
    prm._scrollPosition = null;
}

</script> 

这篇关于ASP.NET AJAX的UpdatePanel问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆