Rendered web control using IPostBackEventHandler.RaisePostBackEvent

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
 
W

William F. Robertson, Jr.

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
 
S

Sam Martin

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
 
S

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
 
W

William F. Robertson, Jr.

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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top