……………………………………………….Expertise in .NET Technologies

Client side scripting and server side scripting

Posted by Ravi Varma Thumati on March 18, 2009

This chapter gives an introduction to client side and server side programming.


Server side code

 In previously, you learned that dynamic pages are created using code in web pages. When you request a page, the web server executes the code in the web page and generates an HTML content for that page. It is this HTML content that is sent back to the browser so that it can be displayed to the user.

The code that is executed by the web server to generate the dynamic page is called “server side code”. It is called “server side code” because it is executed by the web server.

When you develop ASP.NET pages, you will use C# or VB.NET (or any other .NET compatible code) code to write the server side code. Server side code is used to retrieve and generate content for the dynamic pages. You may be using the code to retrieve the content from database or something like that.

When a dynamic page is requested, the server side code is executed on the server and a page is generated. Once the generated page comes to the browser, there is connection with the server. You cannot do anything from the browser to communicate with the server, othen than requesting another page or same page again. So, if you want to access the database or something like that once the page is displayed, it is not possible.

Client side code

Client side code is used to do some kind of basic operations in the browser when the page is displayed to the user.

As you read above, it is not possible to access the server once the page is displayed. Moreover, the browser does not know anything about ASP.NET or .NET. The browser understands only HTML and client side scripting languages.

Client side coding is used to do basic operations on the browser. It cannot be used to access the server or database on the server etc.

Client side coding is done using scripting languages like JavaScript, VbScript, JScript etc. These scripting languages are easy to learn (they are different from and C#). The scripting languages provide only very minimal functionality.

The main use of client side scripting is to validate user input before submitting a page to server. For example, suppose you have a “Registration” page. Once user enter all data and press the “submit” button, all the user input will be sent to server. In the server side, you may have written or C# code to validate all user inputs like Name cannot be empty etc. If the user do not enter a name and press submit, your server side code will generate an error message and return the page to you.

In this case, the page was sent to the server and came back with an error message. It was an expensive operation. It consumed lot of resources to send a page to the server and get it back to the browser with an error message.

If we can catch this validation error in the browser itself, instead of sending to server and coming back with an error, that will save lot of time and resources. User need not wait to send the page to server and come back.

Since, a browser does not know VB.NET or C#, you cannot write such code to validate it in the browser.

Client side scripting comes here to help. You can write JavaScript, VBScript or JScript code to validate the name field in the browser itself and submit it to the server only if all user inputs are correct.



2 Responses to “Client side scripting and server side scripting”

  1. Pleasant evening, you surely have an in depth and illuminating site! I’ll be bookmarking this for sure! Thank you.

  2. I¡¯m delighted that I have noticed this weblog. Finally something not a junk, which we go through incredibly frequently. The website is lovingly serviced and saved up to date. So it must be, thank you for sharing this with us.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: