Rendered web control using IPostBackEventHandler.RaisePostBackEvent

Discussion in 'ASP .Net' started by Sam Martin, Sep 15, 2004.

  1. Sam Martin

    Sam Martin Guest


    I'm making a custom control that is rendered implementing the
    IPostBackEventHandler interface, and have got it working fine for a single
    submit button, but how do i pass arguments from the HTML page back to the
    server, e.g. identify which button has been pressed.

    At the moment i can only cause a postback by using a submit button, are
    there any other ways? - i.e. can a do a manual javascript,
    document.forms[0].submit() ?

    Any help / pointer welcome
    Sam Martin
    Sam Martin, Sep 15, 2004
    1. Advertisements

  2. When you are rendering your button, what are you setting the client onclick
    event to?

    You should be setting the onclick to the Page.GetPostBackClientEvent method.

    I usually pass it this and the args.


    this.Attributes["onclick"] = Page.GetPostBackClientEvent( this, "args" );

    The "args" will be passed to your RaisePostBackEvent method and you could
    process it then.

    William F. Robertson, Jr., Sep 15, 2004
    1. Advertisements

  3. Sam Martin

    Sam Martin Guest

    thanks bill, i just sussed that out, but thanks - at least i know i've got
    it right....but....

    when i perform a callback from an HTML control thats not a submit button,
    the LoadPostData() method is not called.

    it's called when a submit html button submits the form, but not when called
    from an onclick event (from javascript method)

    do you know why that would be?

    thanks again

    Sam Martin, Sep 15, 2004
  4. Sam Martin

    Sam Martin Guest

    ok, i've sussed it.

    need a call to

    if anyone loosks at this for future ref.

    thanks anyway bill


    Sam Martin, Sep 15, 2004
  5. Yes, you were right on track.

    Sorry I didn't get back to you, but you didn't need help anyway. <grin>
    You probably picked up on some other tidbits of knowledge looking it up!


    William F. Robertson, Jr., Sep 15, 2004
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.