Textbox with OnTextChanged Event

Discussion in 'ASP .Net' started by =?Utf-8?B?UGF1bA==?=, Jun 14, 2006.

  1. Hello:

    I create a textbox control programatically something like this:

    Dim td As New TableCell()
    Dim txtbox As New TextBox()
    txtbox.ID = "my_textbox"
    td.Controls.Add(txtbox)

    Now I want to programatically associate a "OnTextChanged" event to this
    textbox.

    How can I do this?

    When I view the page source, the ID of the textbox control is something like
    "ctl00$my_textbox". So the textbox ID actually gets changed.

    Can anyone point me to an example or a link that explains how to do this?

    TIA.

    - Paul
     
    =?Utf-8?B?UGF1bA==?=, Jun 14, 2006
    #1
    1. Advertising

  2. Are you trying to execute a javascript event handler client side when the
    text changes or do you want a post back that will execute server side code?

    "Paul" wrote:

    > Hello:
    >
    > I create a textbox control programatically something like this:
    >
    > Dim td As New TableCell()
    > Dim txtbox As New TextBox()
    > txtbox.ID = "my_textbox"
    > td.Controls.Add(txtbox)
    >
    > Now I want to programatically associate a "OnTextChanged" event to this
    > textbox.
    >
    > How can I do this?
    >
    > When I view the page source, the ID of the textbox control is something like
    > "ctl00$my_textbox". So the textbox ID actually gets changed.
    >
    > Can anyone point me to an example or a link that explains how to do this?
    >
    > TIA.
    >
    > - Paul
     
    =?Utf-8?B?TWFyayBXLiBTcXVpcmVzIElJ?=, Jun 14, 2006
    #2
    1. Advertising

  3. Dim txtbox As New TextBox
    txtbox.ID = "my_textbox"

    AddHandler txtbox.TextChanged, AddressOf <methodname>

    note methodname is the function or sub which will handle the textchange event

    Private Sub txtbox_TextChanged(ByVal sender As System.Object, ByVal e As
    System.EventArgs)
    .....code here
    End Sub


    "Paul" wrote:

    > Hello:
    >
    > I create a textbox control programatically something like this:
    >
    > Dim td As New TableCell()
    > Dim txtbox As New TextBox()
    > txtbox.ID = "my_textbox"
    > td.Controls.Add(txtbox)
    >
    > Now I want to programatically associate a "OnTextChanged" event to this
    > textbox.
    >
    > How can I do this?
    >
    > When I view the page source, the ID of the textbox control is something like
    > "ctl00$my_textbox". So the textbox ID actually gets changed.
    >
    > Can anyone point me to an example or a link that explains how to do this?
    >
    > TIA.
    >
    > - Paul
     
    =?Utf-8?B?TUFDSCBJSQ==?=, Jun 14, 2006
    #3
    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. Henri
    Replies:
    6
    Views:
    770
    Henri
    Aug 6, 2004
  2. Mark Siffer
    Replies:
    3
    Views:
    5,860
    Karl Seguin
    Mar 30, 2005
  3. MattB

    Textbox and OnTextChanged

    MattB, Sep 27, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    5,226
    Scott M.
    Sep 29, 2005
  4. Replies:
    0
    Views:
    554
  5. Paul

    Textbox and onTextChanged Event

    Paul, Jun 14, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    257
    Balasubramanian Ramanathan
    Jun 14, 2006
Loading...

Share This Page