Date post: | 03-Apr-2018 |
Category: |
Documents |
Upload: | manoj-kavedia |
View: | 235 times |
Download: | 0 times |
of 27
7/28/2019 VB.net Exam Questions-s13
1/27
Definition and Usage
The CompareValidator control is used to compare the value of one input control to the value of
another input control or to a fixed value.
Note: If the input control is empty, the validation will succeed. Use the RequiredFieldValidator
control to make the field required.
Properties
Property Description
BackColor The background color of the CompareValidator control
ControlToCompare The name of the control to compare with
ControlToValidate The id of the control to validate
Display The display behavior for the validation control. Legal values are:
None (the control is not displayed. Used to show the error
message only in the ValidationSummary control)
Static (the control displays an error message if validation
fails. Space is reserved on the page for the message even
if the input passes validation.
Dynamic (the control displays an error message if
validation fails. Space is not reserved on the page for the
message if the input passes validation
EnableClientScript A Boolean value that specifies whether client-side validation isenabled or not
Enabled A Boolean value that specifies whether the validation control is
enabled or not
ErrorMessage The text to display in the ValidationSummary control when
validation fails.Note: This text will also be displayed in the
validation control if the Text property is not set
ForeColor The foreground color of the control
id A unique id for the control
IsValid A Boolean value that indicates whether the control specified by
ControlToValidate is determined to be valid
Operator The type of comparison to perform. The operators are:
Equal
GreaterThan
GreaterThanEqual
7/28/2019 VB.net Exam Questions-s13
2/27
LessThan
LessThanEqual
NotEqual
DataTypeCheck
runat Specifies that the control is a server control. Must be set to
"server"
Text The message to display when validation fails
Type Specifies the data type of the values to compare. The types are:
Currency
Date
Double
Integer
String
ValueToCompare A specified value to compare with
Small number:
Big number:
7/28/2019 VB.net Exam Questions-s13
3/27
VB.Net Operator Precedence
Prededence Operator Meaning Associativity15 ( ) Expression Grouping1 Inside-to-outside
14 . Member evaluation Left-to-right
13 ^ Exponentiation Left-to-right
12 - Unary Minus Left-to-right
12 + Unary Plus Left-to-right
11 * Multiplication Left-to-right
11 / Division Left-to-right
10 \ Integer Division Left-to-right
9 Mod Remainder Left-to-right
8 + Addition Left-to-right
8 - Subtraction Left-to-right
8 + String Concatenation Left-to-right
7 & String Concatenation Left-to-right
6 > Bit Shift Right Left-to-right
5 = Equals Left-to-right
5 Not Equals Left-to-right
5 < Less Than Left-to-right
5 Greater Than Left-to-right
5 >= Greater Than Or Equals Left-to-right
5 Like String Pattern Matching Left-to-right
5 Is Reference Equality Left-to-right
5 TypeOf..Is Check Type Left-to-right
4 Not Negation Left-to-right
3 And Complete Evaluation And2 Left-to-right
3 AndAlso Short Circuit And2 Left-to-right
2 Or Complete Evaluation Or2 Left-to-right
7/28/2019 VB.net Exam Questions-s13
4/27
2 OrElse Short Circuit Or2 Left-to-right
2 XOr Exclusive Or2 Left-to-right
1 = Assignment None3
1Parentheses are also used for subroutine and functionevaluation and for array access.
2And, Or, and XOr can be either logical operators of Boolean orbitwise operators on Integer.
3Only one assignment operator is allowed per line.Other assignment operators, new with VB.Net, are +=, -
=, *=, /=, \=, ^=, and &=.
7/28/2019 VB.net Exam Questions-s13
5/27
An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations.
VB.Net is rich in built-in operators and provides following type of commonly used operators:
Arithmetic Operators
Comparison Operators
Logical/Bitwise Operators
Bit Shift Operators
Assignment Operators
Miscellaneous Operators
This tutorial will explain the most commonly used operators.
Arithmetic OperatorsFollowing table shows all the arithmetic operators supported by VB.Net. Assume variable Aholds 2 and
variable B holds 7 then:
Show Examples
Operator Description Example
^ Raises one operand to the power of another B^A will give 49
+ Adds two operands A + B will give 9
- Subtracts second operand from the first A - B will give -5
* Multiply both operands A * B will give 14
/ Divide one operand by another and returns a floating point result B / A will give 3.5
\ Divide one operand by another and returns an integer result B \ A will give 3
MOD Modulus Operator and remainder of after an integer division B MOD A will give 1
Comparison OperatorsFollowing table shows all the comparison operators supported by VB.Net. Assume variable Aholds 10 and
variable B holds 20 then:
Show Examples
Operator Description Example
==Checks if the value of two operands is equal or not, if yes then condition becomes
true.
(A == B) is
not true.
Checks if the value of two operands is equal or not, if values are not equal then
condition becomes true.
(A B) is
true.
>Checks if the value of left operand is greater than the value of right operand, if yes
then condition becomes true.
(A > B) is
not true.
=Checks if the value of left operand is greater than or equal to the value of right
operand, if yes then condition becomes true.
(A >= B) is
not true.
7/28/2019 VB.net Exam Questions-s13
7/27
p q p & q p | q p ^ q
0 0 0 0 0
0 1 0 1 1
1 1 1 1 0
1 0 0 1 1
Assume if A = 60; and B = 13; Now in binary format they will be as follows:
A = 0011 1100
B = 0000 1101
-----------------
A&B = 0000 1100
A|B = 0011 1101
A^B = 0011 0001
~A = 1100 0011
We have seen that the Bitwise operators supported by VB.Net are And, Or, Xor and Not. The Bit shift
operators are >> and
7/28/2019 VB.net Exam Questions-s13
8/27
1111 0000
>>Binary Right Shift Operator. The left operands value is moved right by the number
of bits specified by the right operand.
A >> 2 will
give 15
which is
0000 1111
Assignment OperatorsThere are following assignment operators supported by VB.Net:
Show Examples
Operator Description Example
=Simple assignment operator, Assigns values from right side operands to left side
operand
C = A + B
will assign
value of A +
B into C
+=Add AND assignment operator, It adds right operand to the left operand andassign the result to left operand
C += A is
equivalentto C = C +
A
-=Subtract AND assignment operator, It subtracts right operand from the left
operand and assign the result to left operand
C -= A is
equivalent
to C = C - A
*=Multiply AND assignment operator, It multiplies right operand with the left operand
and assign the result to left operand
C *= A is
equivalent
to C = C * A
/=Divide AND assignment operator, It divides left operand with the right operand
and assign the result to left operand(floating point division)
C /= A is
equivalent
to C = C / A
\=Divide AND assignment operator, It divides left operand with the right operand
and assign the result to left operand (Integer division)
C \= A is
equivalent
to C = C \A
^=Exponentiation and assignment operator. It raises the left operand to the power of
the right operand and assigns the result to left operand.
C^=A is
equivalent
to C = C ^ A
> 2
&=Concatenates a String expression to a String variable or property and assigns the
result to the variable or property.
Str1 &= Str2
is same as
Str1 = Str1
& Str2
Miscellaneous Operators
http://www.tutorialspoint.com/vb.net/vb.net_assignment_operators.htmhttp://www.tutorialspoint.com/vb.net/vb.net_assignment_operators.htm7/28/2019 VB.net Exam Questions-s13
9/27
There are few other important operators supported by VB.Net.
Show Examples
Operator Description Example
AddressOf Returns the address of a procedure.AddHandler Button1.Click,
AddressOf Button1_Click
Await
It is applied to an operand in an
asynchronous method or lambda
expression to suspend execution of
the method until the awaited task
completes.
Dim result As res= AwaitAsyncMethodThatReturnsResult()Await AsyncMethod()
GetType
It returns a Type object for the
specified type. The Type object
provides information about the type
such as its properties, methods, and
events.
MsgBox(GetType(Integer).ToString())
FunctionExpression
It declares the parameters and codethat define a function lambda
expression.
Dim add5 = Function(num As
Integer) num + 5'prints 10Console.WriteLine(add5(5))
If
It uses short-circuit evaluation to
conditionally return one of two
values. The If operator can be
called with three arguments or with
two arguments.
Dim num = 5Console.WriteLine(If(num >= 0,"Positive", "Negative"))
Operators Precedence in VB.Net
Operator precedence determines the grouping of terms in an expression. This affects how an expression is
evaluated. Certain operators have higher precedence than others; for example, the multiplication operatorhas higher precedence than the addition operator:
For example x = 7 + 3 * 2; Here x is assigned 13, not 20 because operator * has higher precedence than +
so it first get multiplied with 3*2 and then adds into 7.
Here operators with the highest precedence appear at the top of the table, those with the lowest appear at
the bottom. Within an expression, higher precedence operators will be evaluated first.
Show Examples
Operator Precedence
Await Highest
Exponentiation (^)
Unary identity and negation (+, -)
Multiplication and floating-point division (*, /)
Integer division (\)
Modulus arithmetic (Mod)
http://www.tutorialspoint.com/vb.net/vb.net_misc_operators.htmhttp://www.tutorialspoint.com/vb.net/vb.net_operators_precedence.htmhttp://www.tutorialspoint.com/vb.net/vb.net_misc_operators.htmhttp://www.tutorialspoint.com/vb.net/vb.net_operators_precedence.htm7/28/2019 VB.net Exam Questions-s13
10/27
Addition and subtraction (+, -)
Arithmetic bit shift ()
All comparison operators (=, , =, Is, IsNot, Like, TypeOf...Is)
Negation (Not)
Conjunction (And, AndAlso)
Inclusive disjunction (Or, OrElse)
Exclusive disjunction (Xor) Lowest
7/28/2019 VB.net Exam Questions-s13
11/27
How to Add Global.asax File in Asp.Net
Posted Date : 3/28/2013 No Of Visit : 115
Introduction : In this article i will show you how you can add a global.asax file in asp.net. In thiswe will also learn to add how to add Global.asax.cs file in asp.net or how to add Code behind file
for Global.asax in asp.net.
Other Related TagAsp.NetC#.Net
In this article i will show you how you can add a global.asax file in asp.net. In this we will also learn to add
how to add Global.asax.cs file in asp.net or how to add Code behind file for Global.asax in asp.net.
Here is the steps.First Create a new asp.net application.
Now right click on the project file and select new item.
http://www.dotnetpools.com/Article/AlldotnetPostedArticleListbycategory/?categoryId=1&CatName=Asp.Nethttp://www.dotnetpools.com/Article/AlldotnetPostedArticleListbycategory/?categoryId=2&CatName=C#.Nethttp://www.dotnetpools.com/Article/AlldotnetPostedArticleListbycategory/?categoryId=1&CatName=Asp.Nethttp://www.dotnetpools.com/Article/AlldotnetPostedArticleListbycategory/?categoryId=2&CatName=C#.Net7/28/2019 VB.net Exam Questions-s13
12/27
Now as you click on the add new item a window will open.
7/28/2019 VB.net Exam Questions-s13
13/27
In above window you will see the global file now select the file and click on Add button .
Now in your Global.asax.cs file youe will get the below code
using System;using System.Collections.Generic;using System.Linq;
7/28/2019 VB.net Exam Questions-s13
14/27
using System.Web;using System.Web.Security;using System.Web.SessionState;
namespace WebApplication5{
public class Global : System.Web.HttpApplication{
protected void Application_Start(object sender, EventArgs e){
}
protected void Session_Start(object sender, EventArgs e){
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
}
protected void Application_AuthenticateRequest(object sender, EventArgs e){
}
protected void Application_Error(object sender, EventArgs e){
}
protected void Session_End(object sender, EventArgs e){
}
protected void Application_End(object sender, EventArgs e){
}}
}
7/28/2019 VB.net Exam Questions-s13
15/27
What is ADO.NET?
ADO.NET is a part of the .NET Framework
ADO.NET consists of a set of classes used to handle data access
ADO.NET is entirely based on XML
ADO.NET has, unlike ADO, no Recordset object
Create a Database Connection
We are going to use the Northwind database in our examples.
First, import the "System.Data.OleDb" namespace. We need this namespace to work with
Microsoft Access and other OLE DB database providers. We will create the connection to the
database in the Page_Load subroutine. We create a dbconn variable as a new
OleDbConnection class with a connection string which identifies the OLE DB provider and the
location of the database. Then we open the database connection:
sub Page_Loaddim dbconndbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & server.mappath("northwind.mdb"))dbconn.Open()end sub
Note: The connection string must be a continuous string without a line break!
Create a Database Command
To specify the records to retrieve from the database, we will create a dbcomm variable as a
new OleDbCommand class. The OleDbCommand class is for issuing SQL queries against
database tables:
sub Page_Load
dim dbconn,sql,dbcommdbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & server.mappath("northwind.mdb"))dbconn.Open()sql="SELECT * FROM customers"dbcomm=New OleDbCommand(sql,dbconn)end sub
7/28/2019 VB.net Exam Questions-s13
16/27
Create a DataReader
The OleDbDataReader class is used to read a stream of records from a data source. A
DataReader is created by calling the ExecuteReader method of the OleDbCommand object:
sub Page_Loaddim dbconn,sql,dbcomm,dbreaddbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & server.mappath("northwind.mdb"))dbconn.Open()sql="SELECT * FROM customers"dbcomm=New OleDbCommand(sql,dbconn)dbread=dbcomm.ExecuteReader()end sub
Bind to a Repeater Control
Then we bind the DataReader to a Repeater control:
Example
sub Page_Loaddim dbconn,sql,dbcomm,dbread
dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & server.mappath("northwind.mdb"))dbconn.Open()sql="SELECT * FROM customers"dbcomm=New OleDbCommand(sql,dbconn)dbread=dbcomm.ExecuteReader()customers.DataSource=dbreadcustomers.DataBind()dbread.Close()dbconn.Close()end sub
Companyname
7/28/2019 VB.net Exam Questions-s13
17/27
ContactnameAddressCity
Show example
Close the Database Connection
Always close both the DataReader and database connection after access to the database is no
longer required:
dbread.Close()dbconn.Close()
http://www.w3schools.com/aspnet/showaspx.asp?filename=demo_dbconn_repeaterhttp://www.w3schools.com/aspnet/showaspx.asp?filename=demo_dbconn_repeater7/28/2019 VB.net Exam Questions-s13
18/27
ASP.NET Database Tutorial
In this tutorial, we will show you how to make a Transact-SQL transaction in a SQL Server database.
We will use ASP.NET 2.0 and VB.NET in the sample.
First, import the namespace ofSystem.Data.SqlClient. The System.Data.SqlClient namespace is
the.NET Framework Data Provider for SQL Server. The.NET Framework Data Provider for SQL Serverdescribes a collection of classes used to access a SQL Server database in the managed space.
Imports System.Data.SqlClient
If you're looking for a really good web host, tryServer Intellect - we found the setup procedure andcontrol panel, very easy to adapt to and their IT team is awesome!
We instantiate a Connections object to connect the sample database of Northwind. Then instantiate a
SqlTransaction object, and associate it to Connections object. The next step is to instantiate aSqlCommand object, set the Transaction property of SqlCommand to SqlTransaction. After then, use
SqlCommand to commit two Sql statements. As one of the statements is incorrect, the transaction willbe rolled back on the error.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)Handles Button1.Click
Dim myConnection As New SqlConnection("Data Source=localhost;InitialCatalog=Northwind;uid=sa;pwd=sa;")
myConnection.Open()
Dim myTrans=myConnection.BeginTransaction()Dim myCommand As New SqlCommand()
myCommand.Connection = myConnectionmyCommand.Transaction = myTransTrymyCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES
(100, 'Description')"myCommand.ExecuteNonQuery()myCommand.CommandText = "delete * from Region where RegionID=101"myCommand.ExecuteNonQuery()
myTrans.Commit()Response.Write("Both records are written to database.")Catch ep As ExceptionmyTrans.Rollback()
Response.Write(ep.ToString())Response.Write("Neither record was written to database.")FinallymyConnection.Close()
End TryEnd Sub
Try Server Intellect forWindows Server Hosting. Quality and Quantity!
The front end Default.aspx page looks something like this:
Transaction
http://www.serverintellect.com/http://www.serverintellect.com/http://www.serverintellect.com/http://www.serverintellect.com/http://www.serverintellect.com/http://www.serverintellect.com/http://www.serverintellect.com/http://www.serverintellect.com/7/28/2019 VB.net Exam Questions-s13
19/27
Transaction
We are using Server Intellect and have found that by far, they are the most friendly, responsive, andknowledgeable support team we've ever dealt with!
The flow for the code behind page is as follows.
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)Handles Button1.Click
Dim myConnection As New SqlConnection("Data Source=localhost;InitialCatalog=Northwind;uid=sa;pwd=sa;")
myConnection.Open()Dim myTrans=myConnection.BeginTransaction()
Dim myCommand As New SqlCommand()myCommand.Connection = myConnectionmyCommand.Transaction = myTransTry
myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES(100, 'Description')"myCommand.ExecuteNonQuery()
myCommand.CommandText = "delete * from Region where RegionID=101"myCommand.ExecuteNonQuery()myTrans.Commit()Response.Write("Both records are written to database.")Catch ep As Exception
myTrans.Rollback()Response.Write(ep.ToString())Response.Write("Neither record was written to database.")Finally
myConnection.Close()End Try
End SubEnd Class
http://www.serverintellect.com/http://www.serverintellect.com/7/28/2019 VB.net Exam Questions-s13
20/27
List all files in a folder with VB.NET
In .NET you can use the DirectoryInfo class of the System.IO namespace to get a list
of files in a particular folder. DirectoryInfo has a GetFiles method that returns a filelist, as FileInfostructures, from the specified directory. Optionally, GetFiles takes a
pattern as a parameter that can limit the list of files returned.
Imports System.IO
Dim strFileSize As String = ""
Dim di As New IO.DirectoryInfo("C:\temp")Dim aryFi As IO.FileInfo() = di.GetFiles("*.txt")
Dim fi As IO.FileInfo
For Each fi In aryFistrFileSize = (Math.Round(fi.Length / 1024)).ToString()
Console.WriteLine("File Name: {0}", fi.Name)
Console.WriteLine("File Full Name: {0}", fi.FullName)Console.WriteLine("File Size (KB): {0}", strFileSize )Console.WriteLine("File Extension: {0}", fi.Extension)
Console.WriteLine("Last Accessed: {0}", fi.LastAccessTime)Console.WriteLine("Read Only: {0}", (fi.Attributes.ReadOnly = True).ToString)
Next
List all folder in the directoryImports System
Imports System.IO
Class Program
SharedSub Main()
ForEach Dir AsStringIn Directory.GetDirectories("c:\Program Files")
Console.WriteLine(Dir)
Next
EndSub
EndClass
7/28/2019 VB.net Exam Questions-s13
21/27
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.Click
' make a reference to a directoryDim di As New IO.DirectoryInfo("c:\")Dim diar1 As IO.FileInfo() = di.GetFiles()Dim dra As IO.FileInfo
'list the names of all files in the specified directoryFor Each dra In diar1
ListBox1.Items.Add(dra)Next
End Sub
Advantages of data setAdvantages are that you can cache the data and do simple filtering and sorting, something thatyou will need for basis things. For advanced things, they are pretty much useless as it is moreproblem then support.
For instance, to filter columns, to construct advanced SQL queeries or something like that, you
will have to apply whole set of workarounds, probably learn XPath (form of SQL in XML world) asnone of those every day operations are not possible native using DataSets...
6.What are the advantages in using a dataset?0
Dataset is a subset of the entire database, catched on your machine without a continuous connection to the
database disconnected architecture which reduce burden on the database server which may help your
application scale well.
what is the difference betweenResponse.Redirect and server.Transfer?
Server.Transfer() : client is shown as it is on the requesting page only, but the all the contentis of the requested page. Data can be persist accros the pages using Context.Itemcollection, which is one of the best way to transfer data from one page to another keeping
the page state alive.
Response.Dedirect() :client know the physical loation (page name and query string as well).Context.Items loses the persisitance when nevigate to destination page. In earlier versions ofIIS, if we wanted to send a user to a new Web page, the only option we had wasResponse.Redirect. While this method does accomplish our goal, it has several importantdrawbacks. The biggest problem is that this method causes each page to be treated as a
http://www.bituh.com/2012/03/31/6-what-are-the-advantages-in-using-a-dataset/http://www.bituh.com/2012/03/31/6-what-are-the-advantages-in-using-a-dataset/#respondhttp://www.codeproject.com/Questions/178831/what-is-the-difference-between-Response-Redirect-ahttp://www.codeproject.com/Questions/178831/what-is-the-difference-between-Response-Redirect-ahttp://www.bituh.com/2012/03/31/6-what-are-the-advantages-in-using-a-dataset/http://www.bituh.com/2012/03/31/6-what-are-the-advantages-in-using-a-dataset/#respondhttp://www.codeproject.com/Questions/178831/what-is-the-difference-between-Response-Redirect-ahttp://www.codeproject.com/Questions/178831/what-is-the-difference-between-Response-Redirect-a7/28/2019 VB.net Exam Questions-s13
22/27
separate transaction. Besides making it difficult to maintain your transactional integrity,Response.Redirect introduces some additional headaches. First, it prevents goodencapsulation of code. Second, you lose access to all of the properties in the Requestobject. Sure, there are workarounds, but theyre difficult. Finally, Response.Redirectnecessitates a round trip to the client, which, on high-volume sites, causes scalabilityproblems.
As you might suspect, Server.Transfer fixes all of these problems. It does this by performingthe transfer on the server without requiring a roundtrip to the client.
In ASP.Net Technology both "Server" and "Response" are objects of ASP.Net. Server.Transfer
and Response.Redirect both are used to transfer a user from one page to another. But there is
some remarkable differences between both the objects which are as follow.
Response.Redirect
1. Response.Redirect() will send you to a new page, update the address bar and add it to
the Browser History. On your browser you can click back.
2. It redirects the request to some plain HTML pages on our server or to some other web
server.
3. It causes additional roundtrips to the server on each request.
4. It doesnt preserve Query String and Form Variables from the original request.
5. It enables to see the new redirected URL where it is redirected in the browser (and be
able to bookmark it if its necessary).
6. Response. Redirect simply sends a message down to the (HTTP 302) browser.
Server.Transfer1. Server.Transfer() does not change the address bar, we cannot hit back.One should use
Server.Transfer() when he/she doesnt want the user to see where he is going. Sometime on a
"loading" type page.
2. It transfers current page request to another .aspx page on the same server.
3. It preserves server resources and avoids the unnecessary roundtrips to the server.
4. It preserves Query String and Form Variables (optionally).
5. It doesnt show the real URL where it redirects the request in the users Web Browser.
6. Server.Transfer happens without the browser knowing anything, the browser request a
page, but the server returns the content of another.
7/28/2019 VB.net Exam Questions-s13
23/27
Server Side and Client Server ScriptingProgramming
Server-side Programming
Server-side programming, is the general name for the kinds of programs whichare run on the Server.
Uses
Process user input.
Display pages.
Structure web applications.
Interact with permanent storage (SQL, files).
Example Languages
PHP
ASP
Nearly any language (C++, C#, Java). But these were not designed
specifically for the task.
Client-side programming
Much like the server-side, Client-side programming is the name for all of the
programs which are run on theClient.
Uses
Make interactive webpages.
Make stuff happen dynamically on the web page.
Interact with temporary storage, and local storage (Cookies, localStorage).
Send requests to the server, and retrieve data from it.
Example languages
JavaScript (primarily)
HTML
CSS
HTML and CSS aren't really "programming languages" per-se. They are the guidelines by which
the Client renders the page for theUser.
7/28/2019 VB.net Exam Questions-s13
24/27
Differences between Client-side and Server-side Scripting
Client-side Environment
The client-side environment used to run scripts is usually a browser. The processing
takes place on the end users computer. The source code is transferred from the web
server to the users computer over the internet and run directly in the browser.
The scripting language needs to be enabled on the client computer. Sometimes if a
user is conscious ofsecurity risks they may switch the scripting facility off. When
this is the case a message usually pops up to alert the user when script is attempting
to run.
Server-side Environment
The server-side environment that runs a scripting language is a web server. Auser's request is fulfilled by running a script directly on the web server to generate
dynamic HTML pages. This HTML is then sent to the client browser. It is usually usedto provide interactive web sites that interface to databases or other data stores on
the server.
This is different from client-side scripting where scripts are run by the viewing web
browser, usually in JavaScript. The primary advantage to server-side scripting is the
ability to highly customize the response based on the user's requirements, access
rights, or queries into data stores.
7/28/2019 VB.net Exam Questions-s13
25/27
The Difference Between Client Side vs. Server Side
Youve no doubt heard the terms server side and client side, or the interchangeable
terms front endand back end. And even if you havent, you should, as the server-client
relationship is an important concept that every web developer should know. But what do
these terms mean?
I was unsure about the meaning of these terms too when I began coding, but it turns out its
quite a simple concept to understand. So heres my explanation of client side vs. server side.
A Client Side Language
When we talk about a client side, or front end, language, 99% of the time were talking about
JavaScript. JavaScript is the definitive front end language used on the web.
The reason its called a client side language is because it runs programs on your computer
(youre the client) after youve loaded a web page. Heres an example:
document.getElementById('hello').innerHTML = 'Hello, world!';
That JavaScript code takes the string Hello, world! and pops it into the element with an ID of
hello lets say it was an .
What was originally inside that element gets replaced, however if you open up the source
code of that page, youll still see that original text and not Hello, world!.
This is because Hello, world! was dynamically added to the HTML document it was not a
part of the original document that was loaded by your browser.
However, what you will be able to see see is the JavaScript code which was run by your
computer.
7/28/2019 VB.net Exam Questions-s13
26/27
A Server Side Language
A server side, or back end, language is different, because it runs its programs before the
HTML is loaded, not after.
Unlike JavaScript, which is the only client side scripting language most websites use, there
are a range of server side languages in use on the web today. PHP is one of the most
popular, as well as Ruby on Rails, ASP.NET and many others.
These are called server side languages because their programs are run not on your
computer, but on the server which hosts the website and sends down the HTML code.
Consider this PHP code:
This code has the exact same effect as the JavaScript code we looked at in the previous
section. It puts the string Hello, world! into the element with an ID of hello.
But view the HTML source and what you see is a different story. Inside the tags will be
the string Hello, world!, right there, written in stone. (OK, perhaps not stone, but you know
what I mean.)
On the other hand, the PHP code that was run by the server will be nowhere to be seen. This
is because the server will have already taken care of the PHP, and what gets sent to your
computer is the resulting pure HTML.
Amazingly, unless youve manually installed PHP, the computer youre on right now wont
have the faintest idea what PHP is. Its never had to deal with it.
7/28/2019 VB.net Exam Questions-s13
27/27