gpt4 book ai didi

c# - AutoPostback 没有正确设置焦点

转载 作者:行者123 更新时间:2023-11-29 22:37:22 24 4
gpt4 key购买 nike

我有一个页面,当发生自动或部分回发时,焦点设置到地址栏而不是下一个控件。有趣的是,当我在我的 RadScriptBlock 中放置一个警报时,在单击“确定”之后,焦点会转到正确的控件 - 或者 - 如果我放入一个无效位置,焦点将返回到 ExpLocation 控件,当正确的位置是第二次输入,tab order/focus 命令正常工作(见下面的代码)。

上面有这个

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadAjaxPanel1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting EventName="OnTextChanged" AjaxControlID="RadNumericTextBox_GLm">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadNumericTextBox_GLm" LoadingPanelID="RadAjaxLoadingPanel1" />
<telerik:AjaxUpdatedControl ControlID="lblGlCodeErrorMessage" LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting EventName="OnTextChanged" AjaxControlID="RadNumericTextBox_ExpLocation">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="lblGlCodeErrorMessage" LoadingPanelID="RadAjaxLoadingPanel1" />
<telerik:AjaxUpdatedControl ControlID="RadNumericTextBox_ExpLocation" LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>

有这个控件..

<telerik:RadNumericTextBox ID="RadNumericTextBox_ExpLocation" runat="server" Width="20px" AutoPostBack="true"
MaxLength="3" NumberFormat-AllowRounding="False" Type="Number" NumberFormat-KeepTrailingZerosOnFocus="True"
IncrementSettings-InterceptMouseWheel="false" OnTextChanged="LocationCheck_OnTextChanged" TabIndex="101">
<NumberFormat DecimalDigits="0" GroupSeparator="" AllowRounding="false" KeepNotRoundedValue="false" />

后面有这段代码

    protected void LocationCheck_OnTextChanged(object sender, System.EventArgs e)
{
var cmdText = "SELECT LMLOC FROM DBMOTO..XALOCNP WHERE " +
" LMLOC = @ExpLocation ";
using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MAINConnectionString"].ToString()))
using (var cmd = new SqlCommand(cmdText, conn))
{
cmd.Parameters.Add(new SqlParameter("@ExpLocation", RadNumericTextBox_ExpLocation.Text));
conn.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
Session["ValidGL"] = false;
lblGlCodeErrorMessage.Visible = false;
lblGlCodeErrorMessage.Text = "Good Location";
btnAddItem.Enabled = false;
btnDone.Enabled = false;
RadNumericTextBox_GLm.Focus();
}
else
{
lblGlCodeErrorMessage.Visible = true;
lblGlCodeErrorMessage.Text = "Invalid/Inactive Location";
btnAddItem.Enabled = false;
btnDone.Enabled = false;
RadNumericTextBox_ExpLocation.Focus();
}
}
}

最佳答案

尝试使用ScriptManager方法设置焦点,禁用ajax,排查异常是否与ajax化有关。 This live demo使用这两种技术,顺便说一句,可以作为您的引用点。

关于c# - AutoPostback 没有正确设置焦点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4556886/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com