Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > responding to changed text doesn't always work

Reply
Thread Tools

responding to changed text doesn't always work

 
 
=?Utf-8?B?am9uZWZlcg==?=
Guest
Posts: n/a
 
      05-23-2006
Private Sub txtLastName_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtLastName.TextChanged
If Me.cmdAction.Text = "Update" Then
Me.cmdAction.Enabled = True
End If
End Sub

The above code seems like it should work but doesn't.

The effect I'm trying to get is to prevent a user from clicking an "update"
button unless the user actually changes anything... so the button is supposed
to stay disabled as long as nothing has changed - but as soon as it changes -
I'd like the button to be available again.

Do I need to consider the IsPostback property to get this to work properly?
 
Reply With Quote
 
 
 
 
Spam Catcher
Guest
Posts: n/a
 
      05-23-2006
=?Utf-8?B?am9uZWZlcg==?= <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> Private Sub txtLastName_TextChanged(ByVal sender As System.Object,
> ByVal e As System.EventArgs) Handles txtLastName.TextChanged
> If Me.cmdAction.Text = "Update" Then
> Me.cmdAction.Enabled = True
> End If
> End Sub
>
> The above code seems like it should work but doesn't.
>
> The effect I'm trying to get is to prevent a user from clicking an
> "update" button unless the user actually changes anything... so the
> button is supposed to stay disabled as long as nothing has changed -
> but as soon as it changes - I'd like the button to be available again.
>


In this case you wouldn't use the TextChanged event - it's only fired on
postback.

You should use a RequiredFieldValidator - this will prevent the update
button from being clicked - tho you should also write a server side event
handler in case the user has javascript disabled.

If you need more flexiblity, you can write custom javascripts to interact
with the built in .NET validators.
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
changed state to up changed state to down FastEthernet LINEPROTO-5-UPDOWN surrealarmada@gmail.com Cisco 3 03-07-2007 06:06 PM
scroll position is changed when style is changed? mxbrunet Javascript 1 11-03-2006 03:40 AM
xmlDocument.Save "&#10;" getting changed changed to "&amp;#10" st@jpa.co.jp ASP .Net 1 10-11-2005 01:30 PM
python+windows/linux -> write stdout text to always on top text? flamesrock Python 5 05-04-2005 06:34 PM
Trying to create a CSS box that is always is always the width of an image placed inside it (and no wider) Deryck HTML 4 06-22-2004 08:25 PM



Advertisments