Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Cl

Discussion in 'ASP .Net' started by jorge, May 25, 2004.

  1. jorge

    jorge Guest

    Hello

    I have the following situation: (everything is dynamic (controls.add))

    1. Button.Init {
    WasButtonClickFired = true
    }

    2. TextBox.TextChanged {
    WasButtonClickFired?
    }

    3. ImageButton.Click {
    }


    I need a way to get the TextChanged event not to fire or at least to know if
    the Click event of a button has been fired.

    Thanks.
    / jorge
     
    jorge, May 25, 2004
    #1
    1. Advertising

  2. I'm not entirely sure of what you're asking, but I have encountered two things which prevent an event handler from dealing with dynamically added control events

    1) You need to add the handler. For instance
    Suppose I have a table cell 'td' which I want to add a linkbutton to programatically..

    Dim lb as new LinkButto
    ' add all the stuff to the linkbutton..

    'Add the handle
    AddHandler lb.OnClick, AddressOf me.lbEventHandle

    'And the lbEventHandler would be your event handler.

    2) Also, look to make sure that you have the controls created again for the postback. If they aren't around after you click on them, the systme won't know what to do

    Hope that helps
    Andrew Wied
     
    =?Utf-8?B?QW5kcmV3IFdpZWQ=?=, May 25, 2004
    #2
    1. Advertising

  3. jorge

    jorge Guest

    Hi Andrew,

    There are no problems with the events. They fire as they should. I recreate
    them in postbacks and all that.

    My question is concerning the fact that TextChanged fires (the event order
    is random right?) before a button event I have from a LinkButton. Now, I
    need to know if the LinkButton (in this case it's a cancel) has been pressed
    so that I can handle my data in the TextChanged event.

    I could not use the TextChanged event and instead load the ViewState and
    compare old with new to set the new in case there wasnt a Cancel. But the
    problem is that would take even more time to implement.

    Another solution would be to learn how to be a gardener and change jobs. or
    wait for Mono and change it so it works MY way.

    Thanks,
    / jorge



    "Andrew Wied" <> wrote in message
    news:...
    > I'm not entirely sure of what you're asking, but I have encountered two

    things which prevent an event handler from dealing with dynamically added
    control events.
    >
    > 1) You need to add the handler. For instance:
    > Suppose I have a table cell 'td' which I want to add a linkbutton to

    programatically...
    >
    > Dim lb as new LinkButton
    > ' add all the stuff to the linkbutton...
    >
    > 'Add the handler
    > AddHandler lb.OnClick, AddressOf me.lbEventHandler
    >
    > 'And the lbEventHandler would be your event handler.
    >
    > 2) Also, look to make sure that you have the controls created again for

    the postback. If they aren't around after you click on them, the systme
    won't know what to do.
    >
    > Hope that helps,
    > Andrew Wied
     
    jorge, May 26, 2004
    #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.

Share This Page