网页中的默认按钮问题 [英] Default button issue in webpage

查看:120
本文介绍了网页中的默认按钮问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个以登录按钮作为默认按钮的登录页面,这样当我按下回车键时,将会引发登录按钮。



我的问题是我第一次输入我的登录ID,pwd然后登录然后浏览器(Chrome)要求保存密码,我已经保存了密码。然后下一次当我打开登录页面时,它正在加载loginid,密码自动当我按下回车键时它要求我输入密码虽然密码已经加载。

但是当我按下回车键再次它的工作。



IE没有发生这种情况,只有谷歌浏览器出错。



如果有人遇到这个问题,请告诉我解决方案。



提前致谢。

解决方案

确保在页面加载时将焦点设置为loginid文本框。 deafult按钮响应表单,因此可能需要将焦点放在该表单中的任何控件上,这似乎是浏览器特定的行为,虽然我不确定这一点。



要在文本框上设置焦点,在页面加载事件中,您可以简单地写 -



 textbox1.Text。 focus(); 





如果这不起作用,试试这个 -



 ScriptManager.RegisterStartupScript( this  this  .GetType() , 焦点  


get(' + textbox1.ClientID + ')。focus(); true );







 ClientScript.RegisterStartupScript( this  this  .GetType(), < span class =code-string>焦点,  


< blockquote> get(' + textbox1.ClientID + ')。focus(); true );





我希望这有效。如果它不起作用,请告诉我。


I have created a login page with login button as default button, so that when I press enter key login button will be raised.

My problem is for the first time i entered my login id, pwd then loggedin then browser(Chrome) asked to save password, i have saved password. then the next time onwards when i opened login page it was loading loginid, password automatically when i press enter key it was asking me to enter password although the password is already loaded.
but when i press enter key again its working.

this was not happening with IE, error is with Google Chrome only.

please tell me the solution if any of you encountered this problem.

Thanks in advance.

解决方案

Make sure that you have set the focus to the "loginid" textbox at the time of page load. The deafult button responds to the form and thus it may need the focus to be on any of the control inside that form which seems to be browser specifi behavior, although I am not sure about this.

To set focus on a textbox, in page load event you may simply write-

textbox1.Text.focus();



If this doesn't work, try this-

ScriptManager.RegisterStartupScript(this, this.GetType(), "Focus", "


get('" + textbox1.ClientID + "').focus();", true);



or

ClientScript.RegisterStartupScript(this, this.GetType(), "Focus", "


get('" + textbox1.ClientID + "').focus();", true);



I hope this works. In case it doesn't work, please let me know.


这篇关于网页中的默认按钮问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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