PC Review


Reply
Thread Tools Rate Thread

Detecting Control Changes

 
 
Michael Albanese
Guest
Posts: n/a
 
      9th Dec 2003
I have an .aspx page which retrieves a record from the
database and populates each field in a ASP:Textbox. I
allow the users to change the contents of individual text
boxes and they click on 'Save' button to save their
changes. Quite often users do not click 'Save' and go to
some other page. How can I programmatically detect that
they have changed one or more text boxes and prompt them
to click on 'Save' button?

Thanks,

Michael

 
Reply With Quote
 
 
 
 
Peter Huang
Guest
Posts: n/a
 
      10th Dec 2003
Hi Michael,

I think you may need try and catch the TextChanged event of textbox and
maintain a viewstate variable ot indicate if the text has changed.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'populate the textbox
If Not IsPostBack Then
TextBox1.Text = "hello"
TextBox2.Text = "world"
viewstate("change") = False
'initialize the st
End If
End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged
viewstate("change") = True
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If viewstate("change") Then
Dim scriptString As String = "<script language=JavaScript>
alert('Please save first')"
scriptString += "</script>"
If (Not Me.IsStartupScriptRegistered("Startup")) Then
Me.RegisterStartupScript("Startup", scriptString)
End If
Else
Response.Redirect("http://www.google.com")
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
'Do save issue
viewstate("change") = False
End Sub

If you have any concern please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting a value change in a control rhardy Microsoft Access VBA Modules 9 12th Mar 2009 04:52 PM
Detecting a tray control Larry Smith Microsoft Dot NET Framework Forms 2 21st Apr 2007 04:21 PM
Detecting user changes to a control James Daughtry Microsoft Dot NET Framework Forms 2 17th Nov 2006 04:41 PM
Detecting a control in a cell? cmpcwil2 Microsoft Excel Programming 1 25th Apr 2006 04:19 PM
Detecting form control events from an add-in Errol Limani Microsoft Outlook Program Addins 3 19th Jul 2004 02:48 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:43 AM.