I have a textboxt which I set the autopostback to true. And when there is textchanged in the textbox, the textchanged event will fire and execute as per the codes i wrote.
It works well when i debug, however the autopostback make the webpage refresh each time the textchanged event is fired.
To prevent the page refresh, I move the textbox into a update panel. I found the textchanged event is not firing after I move the textbox into updatepanel.
What should i do to make the textchanged event fire?
According to your description, I think you may forget to set AutoPostBack=true. In some cases it will not work correctly.
Besides, why do you want to use Reponse.write(), do you want to register the script to the frontend? What needs to be mentioned is that the response.write doesn’t work here. No Postback is involved here. If you want to register the script to the frontend,
I suggest you could use the following method.
Protected Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
'Response.Write("Hello asp net")
ScriptManager.RegisterClientScriptBlock(UpdatePanel1, Me.GetType(), "", "alert('" + TextBox1.Text + "')", True)
End Sub
How it works. Please note the upper left corner refresh bar.
Feel free to let me know if you have any question.
Best Regards,
Abraham
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Thanks for comment. Actually I didn't want to use response.write. Instead, after user keyin the textbox, there will be series of code to read from database and compare the data in database.
I'm using Microsoft visual web developer, and I do set the autopostback to true. Everything work well when the textbox is not in update panel. and it doesnt work if i locate the textbox in update panel... i do include the <trigger> tag but it still not
working..
Member
10 Points
63 Posts
how to make textchanged event works when textbox place in update panel?
Jun 26, 2018 08:41 AM|garfchong|LINK
Dear All Experts,
Good day.
I have a textboxt which I set the autopostback to true. And when there is textchanged in the textbox, the textchanged event will fire and execute as per the codes i wrote.
It works well when i debug, however the autopostback make the webpage refresh each time the textchanged event is fired.
To prevent the page refresh, I move the textbox into a update panel. I found the textchanged event is not firing after I move the textbox into updatepanel.
What should i do to make the textchanged event fire?
thanks in advance for advice.
regards
garf
All-Star
54508 Points
14111 Posts
Re: how to make textchanged event works when textbox place in update panel?
Jun 26, 2018 08:53 AM|mudassarkhan|LINK
TextChanged event will fire in UpdatePanel also provided there is no JavaScript error or some code is preventing PostBack.
Blog: ASPSnippets | Forum: ASPForums | Company: Excelasoft
Contributor
2195 Points
950 Posts
Re: how to make textchanged event works when textbox place in update panel?
Jun 26, 2018 09:24 AM|jimmy69|LINK
Hello all,
@garfchong => why don't you use jquery change event ?
here is it a little sample :
Member
10 Points
63 Posts
Re: how to make textchanged event works when textbox place in update panel?
Jun 26, 2018 10:01 AM|garfchong|LINK
Member
10 Points
63 Posts
Re: how to make textchanged event works when textbox place in update panel?
Jun 26, 2018 10:02 AM|garfchong|LINK
All-Star
54508 Points
14111 Posts
Re: how to make textchanged event works when textbox place in update panel?
Jun 26, 2018 10:12 AM|mudassarkhan|LINK
Share your code
Blog: ASPSnippets | Forum: ASPForums | Company: Excelasoft
Contributor
2195 Points
950 Posts
Re: how to make textchanged event works when textbox place in update panel?
Jun 26, 2018 01:54 PM|jimmy69|LINK
for me it's not a best solution to use textChanged as event on code behind ..because the page is refresh but here is it a little sample
the best solution for me it's to used jquery change event more efficiant ..
All-Star
54508 Points
14111 Posts
Re: how to make textchanged event works when textbox place in update panel?
Jun 26, 2018 02:06 PM|mudassarkhan|LINK
You are using VB, but UpdatePanel uses Javascript to update data without PostBack
Blog: ASPSnippets | Forum: ASPForums | Company: Excelasoft
Member
740 Points
321 Posts
Re: how to make textchanged event works when textbox place in update panel?
Jun 27, 2018 07:39 AM|Abraham Qian|LINK
Hi Garfchong,
According to your description, I think you may forget to set AutoPostBack=true. In some cases it will not work correctly.
Besides, why do you want to use Reponse.write(), do you want to register the script to the frontend? What needs to be mentioned is that the response.write doesn’t work here. No Postback is involved here. If you want to register the script to the frontend, I suggest you could use the following method.
Aspx.
Code behind.
How it works. Please note the upper left corner refresh bar.
Feel free to let me know if you have any question.
Best Regards,
Abraham
Member
10 Points
63 Posts
Re: how to make textchanged event works when textbox place in update panel?
Jun 30, 2018 04:19 PM|garfchong|LINK
Hi Abraham,
Thanks for comment. Actually I didn't want to use response.write. Instead, after user keyin the textbox, there will be series of code to read from database and compare the data in database.
I'm using Microsoft visual web developer, and I do set the autopostback to true. Everything work well when the textbox is not in update panel. and it doesnt work if i locate the textbox in update panel... i do include the <trigger> tag but it still not working..
wondering what went wrong.
thanks and regards
Garf
All-Star
54508 Points
14111 Posts
Re: how to make textchanged event works when textbox place in update panel?
Jun 30, 2018 06:33 PM|mudassarkhan|LINK
AutoPostBack="True" is missing
Blog: ASPSnippets | Forum: ASPForums | Company: Excelasoft