Check if the text box "text" has changed (RePost from web forms forum)

Greetings!

How can i know if the "text" inside of a text box has changed?

For example, I currently have this:

if (txtMU.TextChanged())

{

}

But this does not work. The other idea I had was to assign the existing value of the text box to a string and then when the user click the save button I can create a conditional statement to compare the original string with the new string. However, I would like something more effective as I have like 12 text boxes to compare.

Thanks,

Eduardo


Thanks,

Please Mark this post as answered if it was helpful.
0
EduardoAndres
7/8/2008 3:17:43 PM
asp.net.client-side 24353 articles. 1 followers. Follow

1 Replies
962 Views

Similar Articles

[PageSpeed] 55

Here is the easiest way that I have found.

<form id="form1" runat="server">
 <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
 <input type="button" onclick="onButtonClick();" value="Compare" />
</form>

<script type="text/javascript">
<!--
function onButtonClick(elementRef)
{
 var textBoxRef = document.getElementById('<%= TextBox1.ClientID %>');

 //alert('originalText: ' + textBoxRef.originalText + ' New text: ' + textBoxRef.value);
 if ( textBoxRef.originalText != textBoxRef.value )
  alert('The text in TextBox1 has been changed');
}
// -->
</script>

CodeBehind:
protected void Page_Load(object sender, EventArgs e)
{
    if ( this.IsPostBack )
    {
  //this.Response.Write("originalText: " + TextBox1.Attributes["originalText"] + " New text: " + TextBox1.Text + "<br>");
 }

 TextBox1.Attributes.Add("originalText", TextBox1.Text);
}

NC...

0
NC01
7/8/2008 4:09:30 PM
Reply:

Similar Artilces:

change existing custom field type from "free text" to "large text box"
Is this possible / advisable? If so, how is it done? Thanks, in advance. ...

would like to create script which check if login.Text (from textbox "login") equals "szmitek" and passwod.Text equals "password"
I would like to create script which check if login.Text (from textbox "login") equals "szmitek" and passwod.Text equals "password". I have done it in this way: protected static void Main(string[] args) { string clogin = "szmitek"; string cpassword = "password"; } protected void SubmitBtn_Click(object sender, EventArgs e) { if (HttpUtility.HtmlEncode(login.Text) = (clogin)) if (HttpUtility.HtmlEncode(password.Text) = (cpassword)) { Response.Redirect("admin.aspx"); } else { Response.Redirect("fail.aspx"); } else { Response.Redirect("fail.aspx"); } } But it i...

Request.Form["Label1.Text"]; and ((TextBox)PreviousPage.FindControl("TextBox1")).Text;
Hi I am using request.form[]; to retrive Default.aspx  data in Welcome.aspx page, It works better.But when I am trying to retrive the same data of Welcome.aspx page in the ChangePassword.aspx  page using request.from[]; I am getting blank output, Here is the snippet using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.OleDb;...

Search form "link dropdownlist and the text box" + check input!
I have written a code to perform searching using dropdownlist and textbox but there are several problems with my coding:  1. link the dropdownlist with the textbox: when I tried to run the program there was no connection between the dropdownlist and the textbox what I mean is " If I am selecting for example the author and I am writing B01 which is a bookid it still gives me a result of that book I need to have an error that there is no author with that name or invalid search please check the name ...", I there is something missing with the filtering??? 2. checking user input...

Server-side change to text box trigger causing "late" TextChanged event on postback
I have a page that has two text boxes on it, and an update panel with some content.  If the user changes one text box, the other is adjusted accordingly, and vice versa.  Both text boxes are defined as asyncpostbacktriggers for the update panel, and have AutoPostBack = true. The problem I am having is as follows.  The user changes textbox1.  I get an async textbox1_TextChanged event.  In the event procedure, I change textbox2, and update the UpdatePanel content.  All good.  But on a subsequent change to textbox1, I am getting a textbox2_TextChanged event.&...

superreview requested: [Bug 315633] "Create Profile" dialog text doesn't match button text: "Click Finish"->"Done", "click Next"->"Continue" : [Attachment 206616] Use Mac-appropriate text in profile #3
Daniel Veditz <dveditz@cruzio.com> has asked Benjamin Smedberg [:bs] (bsmedberg@) <benjamin@smedbergs.us> for superreview: Bug 315633: "Create Profile" dialog text doesn't match button text: "Click Finish"->"Done", "click Next"->"Continue" https://bugzilla.mozilla.org/show_bug.cgi?id=315633 Attachment 206616: Use Mac-appropriate text in profile creation https://bugzilla.mozilla.org/attachment.cgi?id=206616&action=edit ------- Additional Comments from Daniel Veditz <dveditz@cruzio.com> blame says bsmed...

superreview requested: [Bug 315633] "Create Profile" dialog text doesn't match button text: "Click Finish"->"Done", "click Next"->"Continue" : [Attachment 206616] Use Mac-appropriate text in profile #2
Steuard Jensen <steuard+mozilla@slimy.com> has asked Daniel Veditz <dveditz@cruzio.com> for superreview: Bug 315633: "Create Profile" dialog text doesn't match button text: "Click Finish"->"Done", "click Next"->"Continue" https://bugzilla.mozilla.org/show_bug.cgi?id=315633 Attachment 206616: Use Mac-appropriate text in profile creation https://bugzilla.mozilla.org/attachment.cgi?id=206616&action=edit ...

How to show "Save changes?" warning after client-side changes in a web-application?
We have a complex web application with a main-menu and sub-menu of tab folders; each tab-folder shows a different screen. Suppose the user selected tab folder A, got the A screen and changed a number in a textbox. Now the user clicks the tab folder B and instead of geting the B screen, the user should get a warning "Save your changes?"On "yes" - save the changes in the A screen and show B, on "no" - discard the A changes and show B. How to do this?   Thanks! Persist the values in the TAB A in a variable(say X), depending on yo...

Change "decimal seperator" by "dot" in text-fields...
When the dot key on the numpad is pressed, the decimal seperator is placed on the screen. Where I live (Beglium), this is a comma. Not a dot. So in numeric fields this is OK. BUT... When our customers press the dot key in the numpad when they are in a text field (filling out phone numbers, VAT-numbers, etc...) they expect a dot, not a comma. How can I force PB to use a dot in text-fields, and a comma in numeric fields, when I press the dot key of the numpad. It isn't an option to change the decimal seperator in Windows, because all other programs wouldn't work correctly...

How can I rename the filed text "OS:" to other text like "Origin"
Hi Folks, I am using bugzilla 2.17.7 to track NONE software bugs. I have redefined the "OS" field to values that describe our reporting requirements better. Now I can not find which template (or other file) I have to edit to change the test "OS:" to "Origin". If this can be done then, which file(s) do I have to edit. Also, I would like to NOT show the field "Hardware" from all forms. Can this be done, if so, which file(s) do I have to edit. Thanks, -shahriar Shahriar wrote: > I am using bugzilla 2.17.7 to track NONE soft...

why do we use Me.Textbox1.text="Demo" instead Textbox1.text="Demo"
I am using asp.net 2.0 tell me what is the reason behind using Me.Textbox1.text ="Demo" instead Textbox1.text="Demo" tell me why do we use Me. thank u maxmax "Me" is just a keyword which refers to the current instance of the class you are within. It's not necessary to use. Some people do, and some people don't. I find it especially helpful when I am deriving my class from a base class and I want to distinguish references to my class (Me) and the base class (MyBase).Thanks, EdMicrosoft MVP - ASP/ASP.NET Me is not neccessary all the time..What i ...

pls help: how to get client-side HTML "text field" value from a server side button
i copy some javascript from somewhere so user can choose pick up a date from a calendar and display the date onto a HTML text field. I have no knowledge in writing client side script(i.e. write code in html) can i write some code in a server-side button to get the value in the HTML text field??? i tried: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click textbox1.text = document.getElementById("htmltext").value End Sub but "document" is highlighted, and say isn't declar yet. and...

C# Calculations based on text box (input type="text")
Hi,I'm new to c# (but not asp.net) and i am having trouble figuring out some calculations I'm trying to work through. I have 2 (input type="text") with different values in each and based on those values I want to do some calculations. In my C# code, when I try and declare a variable to do the calculations the IntelliSense doesnt recognise the input box. When I threw on some regular text boxes it did recognise them... But I cant use textboxesMy 2 input boxes are as follows<input name="ctl00$Content$kgs" value="0" maxlength="5" id="c...

Add "Change Case" in Text Format or right mouse on text
Would be more helpful in scripting and datawindow text formatting, if Change Case is provided. The alternate solution now is to redo the whole text or open an edit tool, while PB itself has a powerful edit tool, except for cool features like this one. Thanks Vairam ...

Web resources about - Check if the text box "text" has changed (RePost from web forms forum) - asp.net.client-side

Resources last updated: 1/28/2016 4:29:08 PM