Rendered web control using IPostBackEventHandler.RaisePostBackEvent

  • Thread starter Thread starter Sam Martin
  • Start date Start date
S

Sam Martin

hi,

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
TIA
Sam Martin
 
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.

IE

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

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

bill
 
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

William F. Robertson said:
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.

IE

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

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

bill

Sam Martin said:
hi,

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
TIA
Sam Martin
 
ok, i've sussed it.

need a call to
Page.RegisterRequiresPostBack(this);

if anyone loosks at this for future ref.

thanks anyway bill

sam

Sam Martin said:
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

William F. Robertson said:
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.

IE

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

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

bill

Sam Martin said:
hi,

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
TIA
Sam Martin
 
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!

bill

Sam Martin said:
ok, i've sussed it.

need a call to
Page.RegisterRequiresPostBack(this);

if anyone loosks at this for future ref.

thanks anyway bill

sam

Sam Martin said:
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

"William F. Robertson, Jr." <wfrobertson_at_kpmg_dot_com> wrote in message
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.

IE

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

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

bill

hi,

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
TIA
Sam Martin
 
Back
Top