ASP文本框调用javascript函数 [英] ASP textbox calls javascript function

查看:120
本文介绍了ASP文本框调用javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp中有一个搜索文本框.而且我希望它每次在此处更改文本时都将请求发送到服务器.我有一个javascript函数,可以发送请求,但是每次在文本框中键入内容时都不会被调用.如何从ASP文本框中调用javascript函数?

I have a search textbox in asp. And I want it to send request to the server each time the text is changed there. I have a javascript function which sends request but it is not being called each time when I type something in the text box. How can I call javascript function from ASP textbox?

那是我的文本框:

<asp:TextBox ID="search" name="Search" runat="server" onchange="javascript:text_changed();"></asp:TextBox>

那是我的js函数:

function text_changed() {
     searchedword = document.getElementById("ContentPlaceHolder1_search").value;
     SendRequest();
}

推荐答案

您应该使用onKeyPress事件来调用该函数.

You should use onKeyPress event to call the function.

<asp:TextBox ID="search" name="Search" runat="server" onKeyPress="javascript:text_changed();"></asp:TextBox>

这篇关于ASP文本框调用javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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