Solved

OnTextChanged event in javascript and asp.net

Posted on 2004-10-05
8
21,963 Views
Last Modified: 2011-08-18
I am using asp.Net with an Iframe.  I want to implement  OnTextChanged event in javascript.
Onclick from the span works, but  not OnTextChanged.  
I only want the confirm or alert when the content is actually changed. onclick does not do that.
Your Help is appreciated.

<span onclick="javascript:confirm('Data has Changed. Click Ok to continue');">
<asp:textbox id=txtNotes
tabIndex=2
runat="server"
Width="472px"
ForeColor="Blue"
ToolTip="Coments-Notes"
Columns="70" MaxLength="70"
Text='<%# DataBinder.Eval(DataView1, "[0].Notes") %>'
Height="100px" TextMode="MultiLine">
</asp:textbox>
</span>

Thanks,
0
Comment
Question by:externet
8 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 500 total points
ID: 12227836
try onchange instead of ontextchanged
0
 
LVL 9

Expert Comment

by:riyasjef
ID: 12230430
Hi
You can implement "OnTextChanged " for the textbox itself..
why u are looking for "span"..I think it will not work..

<asp:textbox id=txtNotes
tabIndex=2
runat="server"
Width="472px"
ForeColor="Blue"
OnTextChanged="text_changed"
ToolTip="Coments-Notes"
Columns="70" MaxLength="70"
Text='<%# DataBinder.Eval(DataView1, "[0].Notes") %>'
Height="100px" TextMode="MultiLine">
</asp:textbox>

and in  C#

void text_changed()
{
   RegisterClientScriptBlock("id","alert('changed')");

}

Riyasjef
0
 

Author Comment

by:externet
ID: 12230851
Hello knightEknight!

onchange works the textbox how about the checkbox?
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:externet
ID: 12230955
Hello riyasjef,

OnTextChanged did not work using vb.net in my
asp.net page using the registerclient script block.
 
0
 
LVL 11

Expert Comment

by:raj3060
ID: 12231987
onchange should work with checkbox, selectbox, radio, text
-Raj
0
 
LVL 25

Expert Comment

by:devic
ID: 12232351
probably, you are waiting direct event, and it fires only if you lost focus.

<input type=checkbox onchange=alert(this.checked)>


CLICK HERE, if the checkbox lost focus you get event onchange
else, you need use onclick event.
0
 
LVL 9

Expert Comment

by:riyasjef
ID: 12242040
Hi

change the fn

void text_changed()
{
   RegisterClientScriptBlock("id","alert('changed')");

}

to

function text_changed()
{
   RegisterClientScriptBlock("id","<script>alert('changed')</script>");
}

Enter the "text" and press enter ..

Riyasjef

0
 

Author Comment

by:externet
ID: 12253093
I would like knightEknight   to have 400 points and  100 points to Riyasjef.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

815 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

8 Experts available now in Live!

Get 1:1 Help Now