ASP.NET

1. ASP.NET Introduction 2. Comp of .Net Framework 3.5 3. Sys.Req for VS 2008 4. ASP.NET Envrmnt Setup 5. VS2010 Ultimate Sys.Req 6. Installing VS 2010 7. VS 2012 Sys.Req 8. Installing VS Exp 2012 9. Start the VS 2008 10. Application Life Cycle 11. Page Life Cycle 12. Page Life Cycle Events 13. ASP.NET Example 14. Event Handling 15. Default Events 16. Server Side 17. Request Object 18. Response Object 19. Server Controls 20. Server Controls Properties 21. Server Controls Methods 22. HTML Server Controls 23. Client Side 24. ASP.NET Basic Controls 25. TextBox Control 26. CheckBox Controls 27. RadioButton Controls 28. ListBox Control 29. HyperLink Control 30. Image Control 31. BulletedList Control 32. ASP.NET Directives 33. Implements Directive 34. Master Type Directive 35. Page Directive 36. PreviousPage Type 37. Managing State 38. Control State 39. Cookies 40. Query Strings 41. Server-Side State 42. Session State 43. Validation Controls 44. Required FieldValidator 45. Range Validator 46. Compare Validator 47. RegularExpressionValidator 48. Custom Validator 49. Validation Summary 50. Data Source Control 51. AdRotator Control 52. Calendar Control 53. Calendar Control Example 54. Panel Control 55. Panel Control Example 56. Multi Views Control 57. MultiView & View controls 58. MultiView Control Example 59. FileUpload Control 60. FileUpload Control Eg 61. AJAX Control 62. UpdatePanel control 63. UpdateProgress Control 64. Custom Controls 65. Custom Control Eg 66. Personalization 67. Create Simple Profile 68. ADO.NET 69. ADO.NET Objects 70. DataTable 71. DataRow 72. DataColumn 73. Object Example 74. Error Handling 75. Tracing Errors 76. Debugger 77. Security 78. Authentication 79. Authorization 80. LINQ 81. LINQ Query Operators 82. LINQ Example 83. Caching 84. Data Caching 85. Output Caching 86. Object Caching 87. Web Services 88. Create Web Services Eg 89. Web & Machine.config 90. Settings Schema 91. ASP.NET Deployment 92. XCopy Deployment 93. Web Setup Project 94. ASP Interview Part 1 95. ASP Interview Part 2 96. ASP Interview Part 3 97. ASP Interview Part 4 98. ASP Interview Part 5 99. ASP Interview Part 6
Pr.Pg Next Pg

ASP.NET Event Handling tutorials

Event

  • An event is a message sent by an object to signal the occurrence of an action.

  • The action could be caused by user interaction, such as a mouse click, or it could be triggered by some other program logic.

  • The object that raises the event is called the event sender. The object that captures the event and responds to it is called the event receiver.

  • Below is an example of some of the event available:

OnClick: Executes when a button is checked

OnSelectedIndexChanged: Executes when an option in dropdownlist is selected.

OnCheckChanged: Executes when a checkbox or radiobutton are checked

 

Application Events

The most important application events are:

    1. Application_Start . it is raised when the application/website is started

    2. Application_End . it is raised when the application/website is stopped

 

Session Events

  • ASP.NET provides two events that help you manage user sessions: the Session_OnStart event, which is raised when a new session begins, and the Session_OnEnd event, which is raised when a session is abandoned or expires.

The Session_OnStart Event:

  • You can handle the Session_OnStart event by adding a subroutine named Session_OnStart to the Global.asax file. The Session_OnStart subroutine is run at the beginning of a request if the request begins a new session. A new session will be started if a request is made that does not contain a SessionID value or if the SessionID property contained in the request references a session that has expired.

  • You can use the Session_OnStart event to initialize session variables as well as to track session-related information.

The Session_OnEnd Event:

  • You can handle the Session_OnEnd event by adding a subroutine named Session_OnEnd to the Global.asax file. The Session_OnEnd subroutine is run when the Abandon method has been called or when the session has expired. A session expires when the number of minutes specified by the Timeout property passes without a request being made for the session.

  • You can use the Session_OnEnd event to clean up session-related information such as information for a user that is tracked in a data source by the SessionID value.


Event Handling Using Controls

  • All ASP.Net controls have events which are fired when user performs certain action on them.

  • For example, when a user clicks a TextBox the 'textbox' event is generated. For handling these events there are in-built attributes and event handlers. To respond to an event, the event handler is coded.

  • By default Visual Studio creates an event handler by including a Handles clause on the Sub procedure. This clause names the control and event that the procedure handles.

  • The following code example shows the markup for aTextBox control for which the TextChanged event is bound to the event handler method named NameChange:

<asp:TextBox ID="textbox1" Runat="server"

Text="" OnTextChanged="NameChange" />

 

  • Now add the event method to your code. For example, the following code example shows the code for the event handler method named NameChange:

protected void NameChange(object sender, EventArgs e)

{

//Method for the OnTextChanged event.

}

 

The common control events are:

 

Event

Attribute

Controls

CheckedChanged

OnCheckedChanged

Check box, radio button

Click

OnClick

Button, image button, link button, image map

Command

OnCommand

Button, image button, link button

SelectedIndexChanged

OnSelectedIndexChanged

List box, drop down list, check box list, radio button list

TextChanged

OnTextChanged

Text box


Pr.Pg border                                              Next Pg