ASP:ontextchanged不触发 [英] ASP: ontextchanged not firing

查看:606
本文介绍了ASP:ontextchanged不触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注:我是全新的ASP.NET。实际上,我训练在周一,但我们有一个热门项目,需要我去潜水和得到完成的,尽我所能。

Note: I am brand new at ASP.NET. I'm actually going to training on Monday, but we have a hot project that required me to dive in and get done as much as I can.

我有我的网页上的文本框,我想它在服务器上调用事件时,它被改变。如果改变是指改变,失去焦点,或者只是每当KEYUP发生了,我不关心。无论哪种情况下会工作。

I've got a textbox on my page, and I would like it to call an event on the server whenever it is changed. I don't care if "changed" means changed and loses focus, or just whenever a keyup happens. Either case will work.

问题是,由于某种原因,每当我改变我的文本框,然后移除焦点,服务器端的方法是没有得到调用。查看通过Chrome浏览器的调试器,我甚至不看正在取得任何形式的AJAX调用的,将告知一个文本框改为服务器。

The issue is that, for some reason, whenever I change my textbox and then remove focus, the server-side method is not getting called. Viewing through the debugger in Chrome, I don't even see any sort of AJAX call being made that would inform the server that a textbox was changed.

我的code:

    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
        <ContentTemplate>
            <asp:TextBox ID="tempTagBuilder" runat="server" 
                CssClass="depBuilder_tempTagBuilder" 
                ontextchanged="tempTagBuilder_TextChanged" AutoPostBack="True"></asp:TextBox>
        </ContentTemplate>
    </asp:UpdatePanel>

ASCX.cs文件

    //whenever the text is changed
    protected void tempTagBuilder_TextChanged(object sender, EventArgs e)
    {
        System.Diagnostics.Debug.WriteLine("Hit");
    }

任何人有什么我的问题可能是个好主意吗?

Anyone have a good idea of what my issue might be?

我得到它的工作(有点)。我不得不进入的UpdatePanel的属性和TextChanged事件添加到触发器集合。不过,现在只要发送它被清空了我的页面上的其他文本框更新!

I got it working (somewhat). I had to go into the updatepanel's properties and add the textchanged event to the triggers collection. However, now whenever it sends the update it is emptying out the other textboxes on my page!

推荐答案

这不火,因为它是在一个更新面板最有可能的。似乎在UpdatePanel需要您设置一个触发事件。

It doesn't fire because it's in an update panel most likely. Seems the updatepanel requires you to set a trigger for the event.

<一个href="http://stackoverflow.com/questions/826023/problem-with-textbox-inside-updatepanel-not-causing-ontextchanged-event">Problem与文本框里面的UpdatePanel - 不会造成OnTextChanged事件

这篇关于ASP:ontextchanged不触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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