Why won't my OnTextChanged event fire

Posted on 2014-09-18
Last Modified: 2014-09-22
Why won't my OnTextChanged event not fire? (VS 2010; C# ASP .NET 4.0)

<asp:TextBox ID="txtToEmailAddresses" runat="server" Width="400px"

    protected void txtToEmailAddresses_TextChanged(object sender, EventArgs e)
        txtSubject.Text = "Completed: " + txtEmpName.Text;
Question by:mikesExpertExchange
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
LVL 18

Expert Comment

by:Jerry Miller
ID: 40330871
Are you performing a partial postback in an update panel? You can set the AutoPostBack="true" in the properties for the textbox.

 <asp:TextBox ID="txtToEmailAddresses" runat="server" Width="400px"
                     ontextchanged="txtToEmailAddresses_TextChanged" AutoPostBack="true"/>

Author Comment

ID: 40330933
ok, that would probably work so i'll give you the points. my current employer is so afraid of anything so "out of the box" as Ajax Tools that they won't want me to use the required toolkit and scriptmanager etc. needed to make this work.
LVL 18

Accepted Solution

Jerry Miller earned 350 total points
ID: 40331218
You don't necessarily have to use the Ajax Toolkit, but I believe that the textbox needs to be in an UpdatePanel so you can see the change. Here is a good example of what I am talking about:

Without using something like Ajax or Jquery, I am not sure that you can see the updates. I use the toolkit controls all over my applications without any issues and my company is pretty strict on what we can do.

Here a couple of good reads on JavaScript and JQuery:

In JavaScript if you use the __doPostBack() method, make sure that your trigger is updating the UpdatePanel where you control is located.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 40333174
Ok, but for the UpdatePanel with the ContentTemplate control, I definitely will need that AjaxToolkit / and library, right?
LVL 13

Assisted Solution

by:jitendra patil
jitendra patil earned 150 total points
ID: 40334143
as Jerry already answered your question, just for your update panel clarification

update panel is control provided by , you don't need any toolkit or library.

 basically it follows the below aspx code pattern

<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
     Email:- <asp:TextBox ID="txtToEmailAddresses" runat="server" Width="400px"
Subject :- <asp:TextBox ID="txtSubject" runat="server" width="400px" />
EmpName:- <asp:TextBox ID="txtEmpName" runat="server" width="400px" />

i've also noted that on your text change event you are setting the values of two different textboxes, so please add those textboxes in the same update panel.

hope this helps.

Author Comment

ID: 40336773
@litendra Patil: Ok, but I do need a scriptmanager tool though, correct?

script manager error

Author Closing Comment

ID: 40336817
Thanks to all who contributed.
LVL 18

Expert Comment

by:Jerry Miller
ID: 40336853
ScriptManager is part of the System.Web.UI.Control, you won't need to Ajax Toolkit for it. Simply import the System.Web.UI.Control.

In the top of your class add,

Using System.Web.UI.Control

This should make the ScriptManager available.

Author Comment

ID: 40337445
Thank you. That did work.
LVL 18

Expert Comment

by:Jerry Miller
ID: 40338168
Cool,  always happy to help!

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question