从javascript强制服务器TextChanged事件 [英] Force server TextChanged event from javascript

查看:110
本文介绍了从javascript强制服务器TextChanged事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp:TextBox,从javascript函数中填充,但是当这种情况发生时,服务器端TextChanged事件不会被触发,只有当我用键盘更改文本。

I've got a asp:TextBox that is populated from a javascript function, but when this happens the server side TextChanged event is not fired, only when I change the text with my keyboard.

是否有解决方案?为什么客户端/服务器集成在asp.net中如此痛苦?

Is there a solution for this? Why is client/server integration so painful in asp.net?

(AutoPostBack设置为true)

(AutoPostBack is set to true)

谢谢

推荐答案

方式1:

function DoPostBack()
{
   __doPostBack("txt_sssn_dt", "TextChanged");
}

Calling ASP.NET server-side events using JavaScript

方式2:

从客户端脚本调用服务器端功能

方式3:

设置焦点丢失的方式之一如下

one of the way to set focus lost like this

function texboxchange() {
        var txtBox = document.getElementById('<%= TextBox4.ClientID %>');
        var count = txtBox.value.length;
        if (count == 2) 
        {
           document.getElementById('<%= TextBox12.ClientID %>').focus();
           return true; // this will call textbox changed event.
        }
    }

这篇关于从javascript强制服务器TextChanged事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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