Jump to content

ASP user control - OnTextChanged event doesn't work!!!!

- - - - -

  • Please log in to reply
4 replies to this topic

#1
rivkic

rivkic

    Newbie

  • Members
  • PipPip
  • 19 posts
I have a web application, with a user control.
In my user control I have a TextBox:

<asp:TextBox ID="Value" runat="server" ontextchanged="TextBox_TextChanged"
ondisposed="Value_Disposed" onload="Value_Load" ></asp:TextBox>


protected void TextBox_TextChanged(object sender, EventArgs e)
{

}

Very simple but it doen't work!
It's skip on the function TextBox_TextChanged!
Please help!!!!:confused:

#2
Momerath

Momerath

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 242 posts
The TextBox Web server control does not raise an event each time the user enters a keystroke, only when the user leaves the control.

By default, the TextChanged event does not immediately cause the Web Forms page to be posted to the server. Instead, the event is raised in server code the next time the form is posted.

#3
rivkic

rivkic

    Newbie

  • Members
  • PipPip
  • 19 posts
Yes, I know it.
I put a break point in that function(TextBox_TextChanged)
and I noticed that I never enterd to this function,
even in postback.
That is my problem.

#4
Momerath

Momerath

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 242 posts
Works fine here, so I'm not sure what to tell you. Are you sure something in your OnLoad event isn't derailing your code?

#5
cdg10620

cdg10620

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 389 posts
Follow Momerath's advice. Make sure that your code isn't breaking before the event is called. You may also want to make sure that you actually registered the event in your .cs file. You should have a section in the .cs file like this:


override protected void OnInit( EventArgs e )

{

    base.OnInit( e );

    txtValue.TextChanged += new EventHandler( txtValue_TextChanged );

}


Hope this helps.
-CDG10620
Software Developer




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users