如何在ASP.NET C#中使用keypress事件,因为事件不包含任何keypress事件。 [英] How to use keypress event in ASP.NET C# because events not containing any keypress event.

查看:142
本文介绍了如何在ASP.NET C#中使用keypress事件,因为事件不包含任何keypress事件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在asp.net c#中使用keypress事件,因为事件不包含任何按键事件。



我尝试过:



我使用了一个html输入框并使用它的onkeypress事件来调用客户端脚本并尝试调用函数后面的代码但是它没有工作然后我使用按钮点击来自客户端脚本和按钮单击我使用搜索功能功能但在按键后它工作但文本框失去焦点。当我使用textbox.focus然后聚焦光标设置在起始位置,我希望它结束​​文本。



谢谢

how to use keypress event in asp.net c# because events not containing any keypress event.

What I have tried:

I have used an html input box and used its onkeypress event to call client script and tried to call code behind function but it did not work then I use button click from client script and in button click i used search function functionality but after keypress it is working but textbox is losing focus. when i am using textbox.focus then while focusing cursor is setting at starting position and i want it to end of text.

thanks

推荐答案

您可以在JavaScript中使用以下代码来实现您的目标。使用你的控件的id而不是'foo'。



You can use the below code in your JavaScript to achieve what you are trying. Use your control's id instead of 'foo'.

var textbox = document.getElementById('foo');
textbox.focus();
textbox.value = textbox.value;


这篇关于如何在ASP.NET C#中使用keypress事件,因为事件不包含任何keypress事件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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