Programming Examples

Are you a Programmer or Application Developer or a DBA? Take a cup of coffee, sit back and spend few minutes here :)

C#

Articles on C# programming language.

ASP 4.0 – Command Button & Event – Lab #007

Step 2 - CommandName Property and Command Event

In the previous Lab, Submit Button Control | Lab #006 we learned how to use submit button and handle its click event. In this lab, we will use three Command Buttons and use Command Event to handle the button click. ASP 4.0 supports grouping the buttons and wiring it to a single event handling routine. We can assign a text string to the CommandText property. Command Event handling routine receives the argument CommandEventArgs and we can enquire the CommandText property on this object to know the event producer and take relevant action. Now, we will proceed with the Lab.

Continue Reading →

ASP 4.0 – Submit Button Control | Lab #006

Step 2 - Handle ASP 4.0 Submit Button Click

When you drop a button control on the ASP.Net Web Form, by default it will act as a Submit Button Control. The submit button performs Auto Postback of the Web Form to the web server. This means, when user clicks the button, the browser will send the Form’s data to the web server. Web Server will process the information and replies back to the web browser. This process is called Postback. In this Lab, we will create a web form with a button control and text field and see how button click works & performs Postback.

Continue Reading →

ASP 4.0 – Label Control | Lab #004

Step 4 - Assign Label Text At Runtime

In ASP.Net, Label Controls display static text. A normal html text is light-weight and suitable to display static text. Means, the text will not change during the lifecycle of the webpage. One can use Label control if its text changes at runtime. The Text property of the Label Control will change the display text. In this Step-by-Step, we will see how to use Label control to display text in it.

Continue Reading →

ASP 4.0 – Understanding Page Events | Lab #003

Step 5 - Start Debug and Observe the Output

In ASP.Net, the client browser will make a request to get a web page. After displaying the page, user can do further navigation via the displayed webpage. In the server side, the server will raise multiple events during the life cycle of a web page. Some of the page events are below:

Page Init: This stage Initializes the page with controls. If any theme needs to be applied, it will be applied here in this phase.

Load: This stage loads the web page with all the controls. In case of post-back, web server will set control properites from the view state. We will learn more about view state in some other article.

Validate: Uses Validator Control and runs validation.

Event Handle: Runs the post-back events. Note, in web application the event happens on the clients browser and its event routines will run on the server at later stage. For Example, let us say a browsing user triggers the text_changed event on the browser end. The event handler routine for the text_changed will run on the server when the user submites text field containing Web-Form or if a post-back occurred. We will learn about post back later.

Render: In this stage, rendering the page for the web -browser occurs. It is a dynamic html generation stage.

Unload: This stage denotes the unloading of the page from the Server memory. After this stage the page becomes no more.

Continue Reading →