Data Binding with ASP.NET part two

Handling PostBack Data

When a form is submitted to a server, the postback event is generated. You might need to process the form data at the server during the postback. The System.Web.UI namespace contains an interface called IPostBackDataHandler that you can use for handling the postback data.

The IPostBackDataHandler interface has two member methods, RaisePostDataChangedEvent() and LoadPostData(). These methods are described as follows:

1. RaisePostDataChangedEvent: This method draws attention of the control to inform any listener about the control's state change. In Visual Basic, the syntax of the method is as follows:
Sub RaisePostDataChangedEvent()

2. LoadPostData: This method handles the postback data of a specific control by processing its postback data. The method returns True if the postback results in state change. On the other hand, if the state does not change after the postback, the method returns False. The method takes two arguments:

postDataKey: This is a String argument that represents the key identifier of the specified control.

postCollection: This argument is an object of the NameValueCollection in the System.Collections
namespace. The argument represents all the incoming name values. In Visual Basic, the syntax of the method is given as follows:

Function LoadPostData(_ByVal postDataKey As String, ByVal postCollection As NameValueCollection) As Boolean After understanding the methods of the IPostBackDataHandler interface, let us see how the postback data is handled. You can handle the postback data only for those server controls that implement the IPostBackDataHandler interface.

When you submit a Web Forms page to the server, the Page Framework searches the content that is posted, for the unique names of the server controls that implement the IPostBackDataHandler interface. Then, for each control that implements this interface, the LoadPostData method is invoked. This method returns True if the state of the control changes.

Otherwise, this method returns False. For all the controls for which the LoadPostData method returns True, the RaisePostDataChangedEvent method is invoked. This method, then, raises the Change events, if any, for the control.

RELATED POST

CREATING ASSEMBLIES WITH ASP.NET

BUILDING HANDLERS IN ASP.NET

INTERFACES AND CLASSES CREATION IN ASP.NET

CACHING IN ASP.NET

CACHING IN ASP.NET PART TWO

WIRE LESS APPLICATION WITH ASP.NET

SECURITY IN ASP.NET PART ONE

SECURITY IN ASP.NET PART TWO

LOCALIZING ASP.NET APPLICATIONS

DEPLOYING ASP.NET APPLICATIONS

ASP.NET CONFIGURATION SYSTEM

WEB SERVICES IN ASP.NET

WEB SERVICES PART TWO

WEB SERVICE INFRASTRUCTURE

WEB SERVICE INFRASTRUCTURE PART TWO

EXCHANGING MESSAGES IN ASP.NET

MICROSOFT HAIL STORM

SOAP AND DOT NET PART ONE

SOAP AND DOT NET PART TWO


No comments:

Post a Comment