使用点击并按回车按钮在asp.net中验证问题? [英] Validation Problem in asp.net using clicking and press enter button?
本文介绍了使用点击并按回车按钮在asp.net中验证问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我点击按钮验证工作时,
按下输入按钮验证不起作用
如何解决这个问题。
如果我输入按钮自动执行代码并转到后面的代码。
错误是:
转换varchar值时转换失败' 1775we '到数据类型int。
提前致谢。
解决方案
< blockquote>要么你可以这样做
这个 .Form.DefaultButton = 此 .btnId.UniqueID;
或
使用Javascript:
功能 clickButton(e,buttonid )
{
var evt = e? e: window .event;
var bt = document .getElementById(buttonid);
if (bt)
{
if (evt.keyCode == 13 )
{
bt.click();
return false ;
}
}
}
In CoeBehind
ContentPage.Attributes.Add( onkeypress, javascript:return
clickButton(event,' + btnSearch.ClientID + '););
Hi,
When I Click the button validation is working,
While press enter button validating is not working
How to solve this problem.
If I enter the button automatically code executed and goes to code behind.
Error Is:
Conversion failed when converting the varchar value '1775we' to data type int.
Thanks in advance.
解决方案
Either you can do this
this.Form.DefaultButton = this.btnId.UniqueID;
or
Using Javascript:
function clickButton(e, buttonid) { var evt = e ? e : window.event; var bt = document.getElementById(buttonid); if (bt) { if (evt.keyCode == 13) { bt.click(); return false; } } }
In CoeBehind
ContentPage.Attributes.Add("onkeypress", "javascript:return clickButton(event,'" + btnSearch.ClientID + "');");
这篇关于使用点击并按回车按钮在asp.net中验证问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文