I have a simple aspx file
<%@ Page Language=\"VB\" AutoEventWireup=\"false\" CodeFile=\"test4.aspx.vb\" Inherits=\"test4\" %>
You need to enable AutoPostBack
on the TextBox that results in the event.
The problem with your code is it's a server-side event trying to invoke a client-side event. The text needs to be entered in TextBox1
and then it will result in the AutoPostBack
.
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"></asp:TextBox>
Based on your need though. It may be better to populate the TextBox2
with the value from TextBox1
using JavaScript.
I know I'm late to the party with this one, but I still wanted to tell my story.
I had a text changed event handler on a read-only TextBox.
JavaScript changed the TextBox to read/write, but the event wouldn't fire. Probably because the back-end still thought it was read-only.
I fixed the issue by moving all changes between R/O and R/W to the back-end. Now it works.
Your TextBox is a server control, and text changed is a server event. It is not meant to be fired each time you type a letter, rather it is fired if the text value is different from the value at the time of the last server post back.
If you need to run some kind of code each time a letter is pressed you will need to register and handle the client-side events OnKeyUp
/ OnKeyDown
/ OnKeyPress
with VB or JavaScripting.
On your .Aspx, add on your TextBox:
OnTextChanged="TextBox1_TextChanged"