How to Fire Validators on TextChange Event

Discussion in 'ASP .Net Web Controls' started by Keith H, Sep 9, 2004.

  1. Keith H

    Keith H Guest

    I have a form with a text box and a button, and I've written my server-side
    button click event handler to handle the events of the textbox's textchanged
    event as well, and that works fine.

    I also have validator controls on the form, and they only work when the
    button is actually clicked; but the browser will submit the form to the
    server when the user enters some text in the text box and presses the <enter>
    key. I want the validators to fire off in both cases.

    I've searched around the newsgroups and forums and tried the following based
    on something I found that was very close to what I wanted (though there was
    no follow-up post to indicate whether it worked or not). This isn't working
    for me:

    Dim strOnChange As String = "if (typeof(Page_ClientValidate) == 'function')
    Page_ClientValidate(); " & Page.GetPostBackClientEvent(txtSlideNo, "")
    txtSlideNo.Attributes.Add("onchange", "this.form.txtSlideNo.click();")

    ....even though I can view source and see the exact same javascript for the
    onchange attribute of my text box that the onclick attribute of my button
    has.

    Can this be done in a relatively simple way? What am I missing?
     
    Keith H, Sep 9, 2004
    #1
    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. Duwayne
    Replies:
    1
    Views:
    1,609
    MS News \(MS ILM\)
    Aug 20, 2003
  2. Anand Sagar
    Replies:
    2
    Views:
    3,546
    Anand Sagar
    Apr 28, 2004
  3. PD
    Replies:
    5
    Views:
    14,514
    Hermit Dave
    Sep 2, 2004
  4. TextBox TextChange Event

    , Jun 25, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    529
  5. nil

    Textchange event

    nil, Jan 2, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    292
Loading...

Share This Page