在回发后设置焦点在html控件上 [英] set focus on the an html control after postback

查看:74
本文介绍了在回发后设置焦点在html控件上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ASP.NET中使用表单,其中下拉列表会导致回发。 **我希望在回发发生后将焦点设置回特定的文本框控件。**





我试过调用



SetFocus(TextBox1.ID)





但我的重点不变。我在Page_Load中调用了这个函数。我在调试模式下运行应用程序并验证TextBox1不是null并且引用了正确的文本框。



顺便说一下TextBox1是一个html控件。这是标记



< input type =textid =TextBox1runat =server/>





这是导致回发的下拉列表





< asp: DropDownList ID =dropdown_finance runat =server

OnSelectedIndexChanged =dropdown_financer_SelectedIndexChanged

AutoPostBack =true>



< asp:ListItem Selected =True>父亲/丈夫

< asp:ListItem>母亲

< asp:ListItem>指定信息财务人员





我只想把焦点设置到我的文本框。怎么做?

I am using a form in ASP.NET where dropdownlists cause postback. **I want to set focus back to a specific textbox control after postback occurs.**


I tried calling

SetFocus(TextBox1.ID)


but my focus is not changing. I called this function in Page_Load. I ran the app in debug mode and verified that TextBox1 is not null and refers to the correct textbox.

By the way TextBox1 is an html control. Here is the markup

<input type="text" id="TextBox1" runat="server" />


Here is the dropdownlist that causes postback


<asp:DropDownList ID="dropdown_finance runat="server"
OnSelectedIndexChanged="dropdown_financer_SelectedIndexChanged"
AutoPostBack="true">

<asp:ListItem Selected="True">Father / Husband
<asp:ListItem>Mother
<asp:ListItem>Specify information of financer


I just want to set focus to my textbox. How to do this?

推荐答案

这个解决方案怎么样?



http://stackoverflow.com/questions/12895098/how-to-set-focus-on-textbox-after-post-back-in -asp-net [ ^ ]



http://stackoverflow.com/questions/2690766/set-focus-on-textbox-after-postback [ ^ ]
How about this solutions ?

http://stackoverflow.com/questions/12895098/how-to-set-focus-on-textbox-after-post-back-in-asp-net[^]

http://stackoverflow.com/questions/2690766/set-focus-on-textbox-after-postback[^]


这篇关于在回发后设置焦点在html控件上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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