Solved

Why won't my OnTextChanged event fire

Posted on 2014-09-18
10
273 Views
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"
                    ontextchanged="txtToEmailAddresses_TextChanged"/>

    protected void txtToEmailAddresses_TextChanged(object sender, EventArgs e)
    {
        txtSubject.Text = "Completed: " + txtEmpName.Text;
    }
0
Comment
Question by:mikesExpertExchange
  • 5
  • 4
10 Comments
 
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"/>
0
 
LVL 1

Author Comment

by:mikesExpertExchange
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.
0
 
LVL 18

Accepted Solution

by:
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:

http://www.codeproject.com/Questions/547212/canplustextchangedpluseventplusofplustextboxplusfi

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:

http://stackoverflow.com/questions/1460288/asp-net-manually-updating-an-updatepanel-using-jquery

http://encosia.com/easily-refresh-an-updatepanel-using-javascript/

In JavaScript if you use the __doPostBack() method, make sure that your trigger is updating the UpdatePanel where you control is located.
0
 
LVL 1

Author Comment

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

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 asp.net , you don't need any toolkit or library.

 basically it follows the below aspx code pattern

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

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.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 1

Author Comment

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

script manager error
0
 
LVL 1

Author Closing Comment

by:mikesExpertExchange
ID: 40336817
Thanks to all who contributed.
0
 
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.

http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager(v=vs.100).aspx
0
 
LVL 1

Author Comment

by:mikesExpertExchange
ID: 40337445
Thank you. That did work.
0
 
LVL 18

Expert Comment

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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now