Q

What does the PostBack method do?

This Content Component encountered an error
What does the PostBack method really do? Why do we use it, when do we use it, and where do we use it?
Postback works by registering a javascript function named __doPostBack emitted by ASP.NET. This function is called by controls that cause postbacks, and causes the page form to be submitted to the server. This function is called passing the ID of the control causing the postback, and an optional argument to pass to the server-side event handler if it exists.

A server-side control can associate a client-side event to this function so that a postback is forced, for example, the "onclick" event on a control such as an image or a link.Your own custom controls can also participate in this process. You only have to use the Page. GetPostBackEventReference(Control control, string argument) method to render the call to the JavaScript client-side function. You also need to implement IPostBackEventHandler so that your control gets called whenever the postback function is called. You have to implement that interface method with the signature:
void RaisePostBackEvent(string eventArgument);
And you use postbacks automatically everytime you attach to an event on a server control.
This was first published in July 2004

Dig deeper on Win Development Resources

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close