Solved

OnTextChanged event in javascript and asp.net

Posted on 2004-10-05
8
21,967 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

792 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