responding to changed text doesn't always work

Discussion in 'ASP .Net' started by =?Utf-8?B?am9uZWZlcg==?=, May 23, 2006.

  1. 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?
    =?Utf-8?B?am9uZWZlcg==?=, May 23, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?am9uZWZlcg==?=

    Spam Catcher Guest

    =?Utf-8?B?am9uZWZlcg==?= <> wrote in
    news::

    > 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.
    Spam Catcher, May 23, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QXJuZQ==?=

    valign=top doesn't always work

    =?Utf-8?B?QXJuZQ==?=, Dec 6, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    415
    =?Utf-8?B?QXJuZQ==?=
    Dec 6, 2004
  2. =?Utf-8?B?QXJuZQ==?=

    Valign=top doesn't always work

    =?Utf-8?B?QXJuZQ==?=, Dec 6, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    583
    Dave Fancher
    Dec 7, 2004
  3. Replies:
    1
    Views:
    672
    Rosanne
    Oct 11, 2005
  4. Hal Vaughan
    Replies:
    11
    Views:
    1,095
    Gordon Beaton
    May 22, 2006
  5. mxbrunet
    Replies:
    1
    Views:
    203
Loading...

Share This Page