Reputation: 2295
I am using the following code to check whether the textbox value is changed. The text box value is initially retrieved from the database in a button click event.
Requirement: I want to update another object(objTest2) property if the tbOffienotes textbox is changed. Further, I want to get only the newly entered text from the text box.
If Not tbOfficeNotes.Text.Equals(objTest.OfficeNotes) Then
Dim strComment As String = tbOfficeNotes.Text.Remove
(0, objTest.OfficeNotes.Length)
'Save the test2 object
objTest2.Comment=strComment
End If
Upvotes: 2
Views: 4721
Reputation: 17724
Subscribe to the TextChanged
event of the textbox. This will be raised when the value changes. You will get the newly entered value in the Text
property of the textbox
Protected Sub tbOfficeNotes_TextChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles tbOfficeNotes.TextChanged
Dim strComment As String = tbOfficeNotes.Text
End Sub
Upvotes: 3
Reputation: 3681
Why don't you store initial value in some control i.e HiddenField
and compare with current value...if changed then do your operation...
Upvotes: 2