2 controls on the same page and wrong events fire

Discussion in 'ASP .Net Building Controls' started by justengland@gmail.com, Jun 2, 2005.

  1. Guest

    I have a button control that uses the <button> tag. I use the render
    control method. I have the name attribute set to the control unique
    id.

    When I have 2 of these buttons on the same page, the page gets confused
    as to what control fired the event. How can I make it work. Basically
    it calls the last event in the list no matter which button I use to
    cause the postback. I use the __dopostback to call the postback. I
    have tried both calls
    psudo code of course
    __dopostback('controlname','');
    and
    __dopostback('unique id','');

    I am sure that many people have had this issue so please help me.

    Thanks
    Justin
    , Jun 2, 2005
    #1
    1. Advertising

  2. Guest

    Have you tried the ClientID?

    Lisa


    wrote:
    > I have a button control that uses the <button> tag. I use the render
    > control method. I have the name attribute set to the control unique
    > id.
    >
    > When I have 2 of these buttons on the same page, the page gets confused
    > as to what control fired the event. How can I make it work. Basically
    > it calls the last event in the list no matter which button I use to
    > cause the postback. I use the __dopostback to call the postback. I
    > have tried both calls
    > psudo code of course
    > __dopostback('controlname','');
    > and
    > __dopostback('unique id','');
    >
    > I am sure that many people have had this issue so please help me.
    >
    > Thanks
    > Justin
    , Jun 2, 2005
    #2
    1. Advertising

  3. Guest

    I have set the unique id = to
    <button id='unique id' onclick=__dopostback('unique id','' >
    , Jun 2, 2005
    #3
  4. Guest

    Well, you didn't say if you tried the ClientID. Have you looked in
    debug mode? Are you using INamingContainer?

    The reason I ask is that if you look at the HTML that gets rendered,
    you'll probably see that the name and the id are different. One has an
    underscore and the other has a colon. I believe it's the id that has
    the underscore. The thing is, it's the name that gets posted back. So
    if you're posting back the id, it may not be identifying the control
    correctly.

    Check it out.

    Lisa


    wrote:
    > I have set the unique id = to
    > <button id='unique id' onclick=__dopostback('unique id','' >
    , Jun 2, 2005
    #4
  5. Guest

    Method 1
    <button ID='btOK' Name='btOK' onclick="__doPostBack('btOK','');">
    <button ID='btOK1' Name='btOK1' onclick="__doPostBack('btOK1','');">
    'Postback fires but no events are raised

    Method 2
    <button ID='btOK1' Name='_ctl0' onclick="__doPostBack('_ctl0','');">
    <button ID='btOK' Name='_ctl1' onclick="__doPostBack('_ctl1','');">
    'btOK click server side event is handled by both controls

    method 3
    <button ID='_ctl0' Name='btOK1' onclick="__doPostBack('_ctl0','');">
    <button ID='_ctl1' Name='btOK' onclick="__doPostBack('_ctl1','');">
    'This worked

    I guess this is the opposite of IPostBackDataHandler which needs the
    unique id as the name.

    I am not sure what bennifit the INamingContainer is since it has 0
    methods defined, but I included it anyway. Thanks for all of your
    help. You made me try all combonations of the javascript, which is
    what fixed the problem.
    , Jun 2, 2005
    #5
    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. Martin
    Replies:
    2
    Views:
    451
    Angrez Singh
    Apr 25, 2005
  2. Mark Sisson

    Calendar Controls don't fire events

    Mark Sisson, Nov 29, 2003, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    112
    Mark Sisson
    Dec 3, 2003
  3. Shawn Meyer

    Dynamically loading ascx page and having events fire

    Shawn Meyer, Jan 31, 2004, in forum: ASP .Net Building Controls
    Replies:
    10
    Views:
    312
    Alessandro Zifiglio
    Feb 9, 2004
  4. Mark Sisson

    Calendar Controls don't fire events

    Mark Sisson, Nov 29, 2003, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    149
    Mark Sisson
    Dec 3, 2003
  5. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    358
    Chris
    Aug 30, 2005
Loading...

Share This Page