在更新表后维护重点AJAX更新面板上 [英] Maintaining focus on ajax update panel after updating form
问题描述
我已经有一个用来更新它的DataSource每个text_changed事件或下拉列表中已被改变的时间一个FormView。在每个text_changed事件,相当于其他控件我称之为formView.UpdateItem方法,这将导致的形式,从我已经标签下到控制失去焦点。
I've have a formview that is designed to update it's datasource each time a text_changed event or dropdown list has been changed. On every text_changed event and equivalent for other controls I call the formView.UpdateItem method and this causes the form to lose focus from the control I have tabbed down to.
我试图实现这种方法但我得到未知的运行时错误后,我试图选择第二次控制。
I've tried to implement this method but I get unknown runtime errors after I have tried to select a control for the second time.
我不禁觉得有处理这个问题的另一种方式。
I can't help but think there is another way of dealing with this.
您会如何去解决这个问题?
How would you go about solving this issue?
推荐答案
有关这样的事情,我经常在ASP藏匿的值:使用JavaScript隐藏控制(INPUT TYPE =隐藏),然后添加一个pageLoad函数中(在JavaScript)来解析该字段,然后设置焦点。通过这种方式,集中控制的ID是通过回传仍然存在。
For things like this, I often stash the value in an asp:Hidden control (input type="hidden") using the javascript and then add a pageLoad function (in the javascript) to parse that field and then set the focus. This way the id of the focused control is persisted through the postback.
是这样的(伪code):
Something like this (pseudocode):
<input type="hidden" id="focusHolder" />
function onSubmit (registered via ClientScript.RegisterOnSubmitStatemnet) {
grab the target and stash id in #focusHolder
}
function pageLoad() {
$get($get('focusHolder').value).focus();
}
这篇关于在更新表后维护重点AJAX更新面板上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!