Ads Header

Saturday, September 4, 2010

ASP .Net Sample Application for the First Timers

Saturday, September 4, 2010 by ASP.NET · 0

This article looks at some of the basics of ASP .Net with a small sample program which writes "Hello World" in the browser.

ASP .Net Class Model:

   The ASP .Net has been built on a collection of classes over the .Net framework. Each control, behavior etc., are implemented using one/many of the .Net classes. These classes could be present either in the Global Assembly Cache (GAC) or the local WWWRoot directories.


   In this model, a web page is derived from System.Web.UI.Page, a user control is derived from System.Web.UI.UserControl, the controls are derived from System.Web.UI.WebControls and tables are derived from System.Web.UI.WebControls.Table etc., The most beautiful feature is all these controls can be accessed via intellisense inside Visual Studio .Net.
   All the HTML and FORM elements defined in a web page are now available as server controls viz., Text Boxes, Labels, List boxes, Dropdown list controls, Tables etc., All of them can be processed on the server (even enabling each control with a client side javascript validations).

The Compiled Page Serving/Execution model in ASP .Net:

   ASP .Net in contrast to older technolgy(ASP), has a compiled model. ASP had an interpreted model where the web server will interpret the .asp page every time when a request for the page is made. But with ASP .Net, the first time load of any page is slower. The reason is because the page gets compiled when the first person makes the request. But subsequently, the pages are loaded at a much faster rate as the server has to execute only the compiled code.
   The file extensions of asp .net are .aspx. The forms in these aspx files can still follow either a "Get" or "Post" Method mechanisms. The major difference in asp .net over the classic asp programming is, the previous model needed atleast two pages for a form post process. i.e., one file for collecting the data and one file for processing the data. With asp .net there is no need for a second file. The same web page can post the data to itself.
   Here is one small sample code, which takes input from a text box inside a web form and displays the input on submitting the form.

<%@ Page language="c#" AutoEventWireup="true"%>
<script language="C#" runat="server">
private void Button1_Click(object sender, System.EventArgs e)
{
lblSample.Text = txtSample.Text;
}
&gl;/script>

<form id="Form1" method="post" runat="server">
<P> <asp:Label id="lblSample" runat="server" Width="208px">Label</asp:Label></P>
<P> <asp:Label id="Label1" runat="server" Width="104px">Enter Text Here:</asp:Label>
<asp:TextBox id="txtSample" runat="server"></asp:TextBox></P>
<P> <asp:Button id="Button1" runat="server" Text="Submit" OnClick="Button1_Click"></asp:Button> </P>
</form>

   The above code can be pasted on to an aspx page and opened in Internet Explorer as http://servername/virtualdirectoryname/sample_page1.aspx. If the folder on which this page is hosted is not configured as a virtual directory in IIS using inetmgr, then the page will not load and will return some errors.
   If this page is written using Webmatrix, then executing this asp .net page is a straight forward mechanism. Open the file in webmatrix and press F5 key. This will automatically open it on a web browser.
   The above page can also be written with a clear separation of the Presentation Layer from the Processing Layer. The .aspx page can be made to host just the HTML and another .cs file can hold the business logic. This is dealt in another article titled Using Code behind in Asp .net.

XML TO HTML Page Creation

by ASP.NET · 0

Script Output:


First NameLast NameSales
AndrewFuller5000
JanetLeverling6250
StevenBuchanan3245
MargaretPeacock4685
RobertKing5290
DavidAndersen6420
FrankEdwards3840
KateRichards4260
EdwardJones3450
LauraCallahan3675
GregMiller5640
TammySteel3570

ASP HTML Download            FAQ
ASP.NET Version By now I'm sure you're probably using XML files for something. Whether it be data transfer, storage, caching, or something else altogether, it's a great technology. Anyway, my point is that you've probably got a few XML files lying around your website. While XML is designed to be human readable as much as it is machine readable, sometimes it's nice to look at something without the <>'s.
This little script will take an XML file and an XSL file and combine them to produce whatever output you want. The sample files (xmlxsl.xml and xmlxsl.xsl) contain a copy of some of our fake sample data and convert it to a basic HTML table, but you can use the same code to transform your data into whatever you want... just change the stylesheet.

Using Remote XML/XSL Files

If you're going to be pulling either the XML of XSL file from a remote server, you should take a look at the remote version of this sample: XML to HTML (via XSL) - Remote Files.

Update: Common Functions for Working with XML and XSL Files

One of our readers read our sample and decided to share a few functions that he's been using to handle his XML and XSL needs. Here's his email:
I've just looked at XML to HTML (via XSL) Classic ASP Sample, and I realised that I've written a few (5) functions for doing this, but with a few enhancements
  1. You can do everything in one function call
  2. The more complicated functions call the simpler ones, keeping everything clean
  3. You can pass parameters into your stylesheet straight from the function call
The functions are:
  • GetXslStyleSheet(ByVal strStyleSheetLocation)
  • GetXslStyleSheetWithParams(ByVal strStylesheetLocation, ByVal strParams)
  • GetXmlDocument(ByVal strDocumentLocation)
  • GetXmlDocumentByStyleSheet(ByVal strDocumentLocation, ByVal strStyleSheetLocation)
  • GetXmlDocumentByStyleSheetWithParams(ByVal strDocumentLocation, ByVal strStyleSheetLocation, ByVal strParams)
Here is the pure file (complete with pseudo XML comments) - I'll write up a little guide to the code if you like it. It's not doing anything special, but I don't think I've noticed anything quite like it being posted before.
Thanks
Chris Surfleet
No Chris... Thank You! I sure many of our users will find the functions extremely helpful. Oh and speaking of the functions, here they are: server-xml.zip (1 KB). Like Chris said, they're pretty simple to figure out and there are basic comments included with the source. Thanks again Chris.

by ASP.NET · 0

Script Output:
First Name Last Name Sales
Andrew Fuller 5000
Janet Leverling 6250
Steven Buchanan 3245
Margaret Peacock 4685
Robert King 5290
David Andersen 6420
Frank Edwards 3840
Kate Richards 4260
Edward Jones 3450
Laura Callahan 3675
Greg Miller 5640
Tammy Steel 3570

By now I'm sure you're probably using XML files for something. Whether it be data transfer, storage, caching, or something else altogether, it's a great technology. Anyway, my point is that you've probably got a few XML files lying around your website. While XML is designed to be human readable as much as it is machine readable, sometimes it's nice to look at something without the <>'s.

This little script will take an XML file and an XSL file and combine them to produce whatever output you want. The sample files (xmlxsl.xml and xmlxsl.xsl) contain a copy of some of our fake sample data and convert it to a basic HTML table, but you can use the same code to transform your data into whatever you want... just change the stylesheet.
Using Remote XML/XSL Files

If you're going to be pulling either the XML of XSL file from a remote server, you should take a look at the remote version of this sample: XML to HTML (via XSL) - Remote Files.
Update: Common Functions for Working with XML and XSL Files

One of our readers read our sample and decided to share a few functions that he's been using to handle his XML and XSL needs. Here's his email:

I've just looked at XML to HTML (via XSL) Classic ASP Sample, and I realised that I've written a few (5) functions for doing this, but with a few enhancements

1. You can do everything in one function call
2. The more complicated functions call the simpler ones, keeping everything clean
3. You can pass parameters into your stylesheet straight from the function call

The functions are:

* GetXslStyleSheet(ByVal strStyleSheetLocation)
* GetXslStyleSheetWithParams(ByVal strStylesheetLocation, ByVal strParams)
* GetXmlDocument(ByVal strDocumentLocation)
* GetXmlDocumentByStyleSheet(ByVal strDocumentLocation, ByVal strStyleSheetLocation)
* GetXmlDocumentByStyleSheetWithParams(ByVal strDocumentLocation, ByVal strStyleSheetLocation, ByVal strParams)

Here is the pure file (complete with pseudo XML comments) - I'll write up a little guide to the code if you like it. It's not doing anything special, but I don't think I've noticed anything quite like it being posted before.

Thanks
Chris Surfleet

No Chris... Thank You! I sure many of our users will find the functions extremely helpful. Oh and speaking of the functions, here they are: server-xml.zip (1 KB). Like Chris said, they're pretty simple to figure out and there are basic comments included with the source. Thanks again Chris.

How to Use the ListBox Control in ASP.NET 2.0

by ASP.NET · 0

How to Use the ListBox Control in ASP.NET 2.0


(Page 1 of 6 )

Any developer who is using the Listbox control in his applications needs to be aware of how data binding has changed from VS 2003 to ADO.NET 2.0. This article will explain the changes. It appears to be an improvement over the previous techniques used.Introduction
While the concept of data binding has not changed, the mechanics and objects involved in data binding have changed from VS2003 (.NET Framework 1.1x) to ADO.NET 2.0. This can be easily seen by comparing the Toolbox items in VS2003 and VS2005 as shown in the next two pictures. The connection, command, transactions, parameters have been replaced by the DataSource Controls. The data binding in ASP.NET 2.0 relies on the data binding expressions and the data source controls. This tutorial is about the ListBox control and how it is bound to data. It should interest those who might be using ListBox Control in their applications. You will see for yourselves how much better off you will be using the Data Source Controls in ADO.NET 2.0.
VS 2003
VS 2005
ListBox Control
The ListBox control displays items in a list appearing sequentially and vertically in a scrollable window. It may display single or multiple items. It usually displays items by pulling the information from memory and formatting them according to the way they are requested. The ListBox control as seen in the Object Browser of VS 2005 has its inheritance as shown in the next paragraph.
Public Class ListBox Inherits System.Web.UI.WebControls.ListControl Member of: System.Web.UI.WebControls Summary: Represents a list box control that allows single or multiple item selection.
This inheritance is common to the other type of list controls as well, such as DropDownList, CheckBoxList, RadioButtonList and the BulletItemList which is new in VS 2005.
Because of this inheritance one can access a large number of properties, methods and events of the list controls in applications shown in the Object Browser.
The ListBox control has additional properties for setting its BorderColor, BorderStyle, and BorderWidth. Also it has some properties not available in other types of list controls, namely Rows and SelectionMode properties shown in the object browser.

How to Use the ListBox Control in ASP.NET 2.0 - Usage of the ListBox Control in web pages


(Page 2 of 6 )

In an  article on VS2003 an example of binding a ListBox control using a DataReader was shown. ListBox can be used to display not only data from a backend database but also other kinds of lists. ListBox events can then be used for displaying list-related information. The following examples use either simple lists or data from a backend database. In the case of a backend database, however, any of the data source controls can be used. For the examples shown an AccessDataSource Control in the VS 2005 IDE is chosen.
On Using the AccessDataSource Control
The AccessDataSource control takes you the very center of RAD. Writing code is almost reduced to a single line. No more connection strings that tangle here, there and everywhere. Most of what you want to do can be done at design time. The IDE even gives you a query editor. An earlier article shows how you may use this data source control with a large number of screen shots. A few major screen shots are shown here.
Step 1
You must first add a source to the data connection, which will add the nwind.mdb file on your local drive as shown in the Server Explorer window. In this picture it is shown as being refreshed.

Step 2
Next you bring the connection to the App_Data folder of your website. When this is accomplished your website should appear as shown in the following picture.

How to Use the ListBox Control in ASP.NET 2.0 - ListBox Examples


(Page 3 of 6 )

Simple List
This example shows filling a ListBox with several items at design time. The next picture shows the ListBox on the design pane filled in with three items. The List Items Collection Editor dialog can be popped up by clicking on an empty space in the items collection property in the List Box properties window shown in the same picture on its right. In this Editor you can begin adding items by providing Key/ Value pairs as shown  for "New Jersey."
Another way of doing this is to follow the ListBox tasks as shown in the next picture by clicking the smart tags arrow attached to the ListBox. This will be discussed later in the tutorial.
By using the SelectedIndexChanged event you may be able to write a code so that the Key Value of selected items is displayed in the textbox as shown in the following snippet.
Partial Class Simplelist
   Inherits System.Web.UI.Page

   Protected Sub ListBox1_SelectedIndexChanged(ByVal sender _
   As Object, ByVal e As System.EventArgs) Handles _
   ListBox1.SelectedIndexChanged
     TextBox1.Text = ListBox1.SelectedValue.ToString
   End Sub
End Class

The source code for this  program (SimpleList.aspx) is shown in the following listing.
<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="Simplelist.aspx.vb" Inherits="Simplelist" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
   <title>Simple List</title>
</head>
<body>
   <form id="form1" runat="server">
   <div>
     <asp:ListBox ID="ListBox1" runat="server"
AutoPostBack="true" >
        <asp:ListItem Value="NJ">New Jersey</asp:ListItem>
        <asp:ListItem Value="C0">Colorado</asp:ListItem>
        <asp:ListItem Value="NY">New York</asp:ListItem>
     </asp:ListBox>
     <asp:TextBox ID="TextBox1" runat="server" Text=''>
     </asp:TextBox></div>
  </form>
</body>
</html>

The result of opening this page in the browser and selecting any of the list items will display its key value in the textbox as shown in the next picture.
The selected item is bound to a textbox with a Binding expression.
This example is similar to the previous one, but the Selected Item's value is bound to the textbox with a binding expression as shown in the code used for the "text" property of the textbox. Adding items to the ListBox is similar to the previous example. The ListBox and the textbox are tied up in the form1_load() event as shown in the following snippet for the code behind for this page, BindingExp.aspx.
Partial Class BindingExp Inherits System.Web.UI.Page Protected Sub form1_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles form1.Load DataBind() End Sub End Class
The source code for this page (BindingExp.aspx) is shown in the following listing.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="BindingExp.aspx.vb" Inherits="BindingExp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
   <title>Bound List</title>
</head>
<body>
   <form id="form1" runat="server">
   <div>
     <asp:ListBox ID="ListBox1" runat="server"
AutoPostBack="true">
       <asp:ListItem Value="57">John</asp:ListItem>
       <asp:ListItem Value="35">Tom </asp:ListItem>
       <asp:ListItem Value="22">Lisa</asp:ListItem>
     </asp:ListBox>
     <asp:TextBox ID="TextBox1" runat="server" Text="<%#
ListBox1.SelectedValue %>">
    </asp:TextBox>
</div>
   </form>
</body>
</html>

How to Use the ListBox Control in ASP.NET 2.0 - Dynamic binding to data at run time


(Page 4 of 6 )

There are two ways you can populate the list with backend data. Well, not exactly two ways so much as two procedures using  the same AccessDataSource Control.
Example 1: The Long hand
The first of these is a roundabout way of getting the result. It still uses the AccessDataSource control by starting off using its connectionString as shown in the following (litany?) snippet. This was how data was accessed using ADO.NET 1.0.
Imports System.Data.OleDb
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 ds As New AccessDataSource
     ds = AccessDataSource1
     Response.Write(ds.ConnectionString)
     Dim mycon As New OleDbConnection
     Dim conStr As String = ds.ConnectionString
     mycon.ConnectionString = conStr
     mycon.Open()
     Response.Write("<h2>" & mycon.State & "</h2>")
     Dim myCmd As New OleDbCommand
     myCmd.Connection = mycon
     myCmd.CommandType = Data.CommandType.Text
     myCmd.CommandText = ds.SelectCommand.ToString
     Try
       Dim dr As OleDbDataReader = myCmd.ExecuteReader
       Response.Write(dr.HasRows)
       'Dim str As String = ""
       While dr.Read
         ListBox1.Items.Add(dr.Item("CustomerID") & _
         "," & dr.Item("CompanyName") & "," & _
                           dr.Item("LastName") & "," & _
                            dr.Item("City") & "," _
                            & dr.Item("HomePhone"))
         'Response.Write(str)
       End While
       dr.Close()
     Catch ex As System.Data.OleDb.OleDbException
       Response.Write(ex.Message)
     End Try

     mycon.Close()
   End Sub
End Class

You may recall that this code is similar to what was formerly used in the VS2003 and described in a previously referenced article. The Design pane of this page (Default.aspx) is shown in the next picture followed by the source code listing of the page. In the source code make sure that the SelectCommand is all in one line. It should work as is except that the VS2005 IDE editor may emit some errors (it will work in spite of the emitted HTML error).
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
   <title>Longwinded</title>
</head>
<body>
   <form id="form1" runat="server">
   <div id="DIV1" runat="server">
     <asp:ListBox ID="ListBox1" runat="server"
     AppendDataBoundItems="True" AutoPostBack="false"
     Height="172px" Width="650px" >

     </asp:ListBox><asp:AccessDataSource        ID="AccessDataSource1" runat="server"
       DataFile="~/App_Data/nwind.mdb"
       SelectCommand="SELECT Customers.CustomerID,
       Customers.CompanyName, Customers.ContactName,
       Employees.LastName, Employees.City, Employees.HomePhone,
       Orders.OrderDate
       FROM ((Customers INNER JOIN Orders ON
       Customers.CustomerID = Orders.CustomerID)
       INNER JOIN Employees ON
       Orders.EmployeeID = Employees.EmployeeID)
       WHERE (Orders.OrderDate > #5/1/1998#)"
>
       </asp:AccessDataSource>
     <asp:Button ID="Button1" runat="server"
Text="Button" /></div>
   </form>
</body>
</html>

Example 2: Using DataSource directly
The code behind shown for this CodeBound.aspx is simple and effortless  thanks to the ADO.NET 2.0 DataSource controls. Some of the AccessDataSource controls' properties are used.  The source code listing is also simpler as shown. The design pane of this example is exactly the same as in the previous example (Default.aspx). For this example you add the ListBox to the design pane and attach the datasource; you can get drop-down hints for writing the code.
First, the code behind the click event of the button.
Imports System.Data.OleDb
Partial Class CodeBound
   Inherits System.Web.UI.Page

   Protected Sub Button1_Click(ByVal sender As Object, _
   ByVal e As System.EventArgs) Handles Button1.Click
     Dim ds As New AccessDataSource
     ds = AccessDataSource1
     Dim sqlstr As String = "Select * from Customers"
     ds.SelectCommand = sqlstr

     ListBox1.DataSource = ds
     ListBox1.DataValueField = "CustomerID"
     ListBox1.DataTextField = "CompanyName"
     ListBox1.DataBind()
   End Sub
End Class

The source code listing of CodeBound.aspx is much simpler than the previous case as shown below. Less code is the key word here.
<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="CodeBound.aspx.vb" Inherits="CodeBound" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
   <title>Code Bound</title>
</head>
<body>
   <form id="form1" runat="server">
   <div>
     <asp:ListBox ID="ListBox1" runat="server" Height="177px"
Width="333px">
     </asp:ListBox><asp:AccessDataSource
       ID="AccessDataSource1" runat="server"
       DataFile="~/App_Data/nwind.mdb"
       SelectCommand="SELECT [CustomerID], [CompanyName],
                   [City], [Phone] FROM [Customers]">
     </asp:AccessDataSource>
     <br />
     <br />
     <asp:Button ID="Button1" runat="server"
Text="Button" /></div>
    </form>
</body>
</html>

This page gets rendered as shown in the next picture when the button is clicked.

How to Use the ListBox Control in ASP.NET 2.0 - Databound ListBox Example


(Page 5 of 6 )

In the previous two examples the ListBox was not bound to data at design time (see the design pane). In the following example the ListBox is bound to the DataSource as seen in the design view of this page, BoundList.aspx.
The source code for this page is as shown here.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server"> 
   <title>Databound Expression</title>
</head>
<body>
   <form id="form1" runat="server">
   <div>
     <asp:ListBox ID="ListBox1" runat="server"
       DataSourceID="AccessDataSource1"
       DataTextField="ContactName"
       DataValueField="City"
       AutoPostBack="True" >

     </asp:ListBox><asp:AccessDataSource ID="AccessDataSource1"
       runat="server" DataFile="~/App_Data/nwind.mdb"
       SelectCommand="SELECT [CustomerID], [CompanyName],
           [ContactName],
           [Address], [City], [Phone] FROM [Customers]" >
     </asp:AccessDataSource>

   </div>
     <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
   </form>
</body>
</html>

There is no code behind to populate the list. The list is bound to data at design time. This is indeed an excellent enhancement for those who do not want to use the code but who are adept at designing using the IDE. There is some code behind but that is only for displaying a selected value in a textbox as show here.
Partial Class BoundList
   Inherits System.Web.UI.Page

   Protected Sub ListBox1_SelectedIndexChanged(ByVal sender _
   As Object, ByVal e As System.EventArgs) Handles _
   ListBox1.SelectedIndexChanged
     TextBox1.Text = ListBox1.SelectedValue
   End Sub
End Class

The following picture shows how this page gets rendered when the button is clicked. Note that the ListBox's Selected value really references the DataFieldValue in the source code.

How to Use the ListBox Control in ASP.NET 2.0 - Steps in converting a Unbound ListBox to a Bound ListBox


(Page 6 of 6 )

The starting point is to drop a ListBox control on the design pane. Then click the smart tag arrow attached to the ListBox at top right to open the tasks window as shown.
Now click the Choose Data Source... hyperlink to open the next page of the wizard.
In this wizard use the drop-down to choose AccessDataSource1. This may open up other drop-downs. Since you are not sure of the item and the dropdown does not show any items, just click OK.
This modifies the task list to add a new item, Configure Data Source... as shown.
Click on Configure Data Source settings, which opens up the next screen. This screen comes up with the datasource you have already configured as shown in the next picture.
Click on the Next button  to reveal the next screen, Configure the Select Statement. Here you can do a lot of filtering and sorting of data using all the clauses of the SQL SELECT statement. For this example only the "City" column is chosen.
A click on the next button takes you to the following screen, Test Query, where you can test the query as shown using the Test Query button.
When you click the Finish button you get bound to data as shown in the next picture. You may also enable AutoPostBack.
Summary
This tutorial described the various ways a ListBox server control in ASPNET 2.0 gets populated with either hard coded data or data from a backend database. An MS Access 2003 database was used. The ADO.NET 2.0 Data Source Controls makes the coding much easier. The GUI provides all the necessary items for fashioning appropriate queries.
The ListBox event can be put to good use in drilling down on the data. Much of the drudgery encountered in ADO.NET 1.0 is removed for good. When configuring tasks it is advisable to switch to the source code and verify that the elements are properly configured. If you still want to use the tortuous route, you can take the route suggested in one of the examples.

DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

CompareValidator in ASP.net

by ASP.NET · 0

<html>
<body>

<form runat="server">
<table border="0" bgcolor="#b0c4de">
   <tr valign="top">
     <td colspan="4"><h4>Compare two values</h4></td>
   </tr>
   <tr valign="top">
     <td><asp:TextBox id="txt1" runat="server" /></td>
     <td> = </td>
     <td><asp:TextBox id="txt2" runat="server" /></td>
     <td><asp:Button Text="Validate" runat="server" /></td>
   </tr>
</table>
<br />
<asp:CompareValidator
id="compval"
Display="dynamic"
ControlToValidate="txt1"
ControlToCompare="txt2"
ForeColor="red"
BackColor="yellow"
Type="String"
EnableClientScript="false"
Text="Validation Failed!"
runat="server" />
</form>

</body>
</html>

JAVA

by ASP.NET · 0


What is Java technology and why do I need it?


This article applies to:
  • Platform(s): All Platforms
  • Java version(s): All JRE Versions

Java is a programming language and computing platform first released by Sun Microsystems in 1995. It is the underlying technology that powers state-of-the-art programs including utilities, games, and business applications. Java runs on more than 850 million personal computers worldwide, and on billions of devices worldwide, including mobile and TV devices.

Why do I need Java?
There are lots of applications and websites that won't work unless you have Java installed, and more are created every day. Java is fast, secure, and reliable. From laptops to datacenters, game consoles to scientific supercomputers, cell phones to the Internet, Java is everywhere!
Is Java free to download?
Yes, Java is free to download. Get the latest version at http://java.com.
If you are building an embedded or consumer device and would like to include Java, please contact Oracle for more information on including Java in your device.

Why should I upgrade to the latest Java version?
The latest Java version contains important enhancements to improve performance, stability and security of the Java applications that run on your machine. Installing this free update will ensure that your Java applications continue to run safely and efficiently.

MORE TECHNICAL INFORMATION

Originally called OAK, it was renamed as the Java programming language in 1995.

What will I get when I download Java software?
The Java Runtime Environment (JRE) is what you get when you download Java software. The JRE consists of the Java Virtual Machine (JVM), Java platform core classes, and supporting Java platform libraries. The JRE is the runtime portion of Java software, which is all you need to run it in your Web browser. When you download Java software, you only get what you need - no spyware, and no viruses.
What is Java Plug-in software?
The Java Plug-in software is a component of the Java Runtime Environment (JRE). The JRE allows applets written in the Java programming language to run inside various browsers. The Java Plug-in software is not a standalone program and cannot be installed separately.
I've heard the terms Java Virtual Machine and JVM. Is this Java software?
The Java Virtual Machine is only one aspect of Java software that is involved in web interaction. The Java Virtual Machine is built right into your Java software download, and helps run Java applications.

INSTALLING ASP.Net

by ASP.NET · 0

What You Need

If you have a Beta version of ASP.NET installed, we recommend that you completely uninstall it!
Or even better: start with a fresh Windows 2000 or XP installation!

Windows 2000 or XP

If you are serious about developing ASP.NET applications you should install Windows 2000 Professional or Windows XP Professional.
In both cases, install the Internet Information Services (IIS) from the Add/Remove Windows components dialog.

Service Packs and Updates

Before ASP.NET can be installed on your computer, all relevant service packs and security updates must be installed.
The easiest way to do this is to activate your Windows Internet Update. When you access the Windows Update page, you will be instructed to install the latest service packs and all critical security updates. For Windows 2000, make sure you install Service Pack 2. You should also install the latest version of Internet Explorer.
Tip: Read the note about connection speed and download time at the bottom of this page.

Install .NET

From your Windows Update you can now select the Microsoft .NET Framework.
After download, the .NET framework will install itself on your computer - there are no options to select for installation.
You are now ready to develop your first ASP.NET application!

The .NET Software Development Kit

If you have the necessary bandwidth, you might consider downloading the full Microsoft .NET Software Development Kit (SDK).
We fully recommend getting the SDK for learning more about .NET, and for the documentation, samples, and tools included.

Connection Speed and Download Time

If you have a slow Internet connection, you might have problems downloading large files like the Windows 2000 Service Pack 2 and the Microsoft .NET Framework.
If download speed is a problem, our best suggestion is to get the latest files from someone else, from a colleague, from a friend, or from one of the CDs that comes with many popular computer magazines.

ASP.net

by ASP.NET · 0

ASP.NET has better language support, a large set of new controls, XML-based components, and better user authentication.

ASP.NET provides increased performance by running compiled code.

ASP.NET code is not fully backward compatible with ASP.
New in ASP.NET

    * Better language support
    * Programmable controls
    * Event-driven programming
    * XML-based components
    * User authentication, with accounts and roles
    * Higher scalability
    * Increased performance - Compiled code
    * Easier configuration and deployment
    * Not fully ASP compatible

Language Support

ASP.NET uses ADO.NET.

ASP.NET supports full Visual Basic, not VBScript.

ASP.NET supports C# (C sharp) and C++.

ASP.NET supports JScript.
ASP.NET Controls

ASP.NET contains a large set of HTML controls. Almost all HTML elements on a page can be defined as ASP.NET control objects that can be controlled by scripts.

ASP.NET also contains a new set of object-oriented input controls, like programmable list-boxes and validation controls.

A new data grid control supports sorting, data paging, and everything you can expect from a dataset control.
Event Aware Controls

All ASP.NET objects on a Web page can expose events that can be processed by ASP.NET code.

Load, Click and Change events handled by code makes coding much simpler and much better organized.
ASP.NET Components

ASP.NET components are heavily based on XML. Like the new AD Rotator, that uses XML to store advertisement information and configuration.
User Authentication

ASP.NET supports form-based user authentication, cookie management, and automatic redirecting of unauthorized logins.
User Accounts and Roles

ASP.NET allows user accounts and roles, to give each user (with a given role) access to different server code and executables.
High Scalability

Much has been done with ASP.NET to provide greater scalability.

Server-to-server communication has been greatly enhanced, making it possible to scale an application over several servers. One example of this is the ability to run XML parsers, XSL transformations and even resource hungry session objects on other servers.
Compiled Code

The first request for an ASP.NET page on the server will compile the ASP.NET code and keep a cached copy in memory. The result of this is greatly increased performance.
Easy Configuration

Configuration of ASP.NET is done with plain text files.

Configuration files can be uploaded or changed while the application is running. No need to restart the server. No more metabase or registry puzzle.
Easy Deployment

No more server-restart to deploy or replace compiled code. ASP.NET simply redirects all new requests to the new code.
Compatibility

ASP.NET is not fully compatible with earlier versions of ASP, so most of the old ASP code will need some changes to run under ASP.NET.

To overcome this problem, ASP.NET uses a new file extension ".aspx". This will make ASP.NET applications able to run side by side with standard ASP applications on the same server.

What is Asp.net ?

by ASP.NET · 0

What You Should Already Know

Before you continue you should have a basic understanding of the following:
  • WWW, HTML, XML and the basics of building Web pages
  • Scripting languages like JavaScript or VBScript
  • The basics of server side scripting like ASP or PHP
If you want to study these subjects first, find the tutorials on our

What is Classic ASP?

Microsoft's previous server side scripting technology ASP (Active Server Pages) is now often called classic ASP.
ASP 3.0 was the last version of classic ASP.
To learn more about classic ASP, you can study our 

ASP.NET is NOT ASP

ASP.NET is the next generation ASP, but it's not an upgraded version of ASP.
ASP.NET is an entirely new technology for server-side scripting. It was written from the ground up and is not backward compatible with classic ASP.
You can read more about the differences between ASP and ASP.NET in the next chapter of this tutorial.
ASP.NET is the major part of the Microsoft's .NET Framework.

What is ASP.NET?

ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be executed by an Internet server.
  • ASP.NET is a Microsoft Technology
  • ASP stands for Active Server Pages
  • ASP.NET is a program that runs inside IIS
  • IIS (Internet Information Services) is Microsoft's Internet server
  • IIS comes as a free component with Windows servers
  • IIS is also a part of Windows 2000 and XP Professional

What is an ASP.NET File?

  • An ASP.NET file is just the same as an HTML file
  • An ASP.NET file can contain HTML, XML, and scripts
  • Scripts in an ASP.NET file are executed on the server
  • An ASP.NET file has the file extension ".aspx"

How Does ASP.NET Work?

  • When a browser requests an HTML file, the server returns the file
  • When a browser requests an ASP.NET file, IIS passes the request to the ASP.NET engine on the server
  • The ASP.NET engine reads the file, line by line, and executes the scripts in the file
  • Finally, the ASP.NET file is returned to the browser as plain HTML

What is ASP+?

ASP+ is the same as ASP.NET.
ASP+ is just an early name used by Microsoft when they developed ASP.NET.

The Microsoft .NET Framework

The .NET Framework is the infrastructure for the Microsoft .NET platform.
The .NET Framework is an environment for building, deploying, and running Web applications and Web Services.
Microsoft's first server technology ASP (Active Server Pages), was a powerful and flexible "programming language". But it was too code oriented. It was not an application framework and not an enterprise development tool.
The Microsoft .NET Framework was developed to solve this problem.
.NET Frameworks keywords:
  • Easier and quicker programming
  • Reduced amount of code
  • Declarative programming model
  • Richer server control hierarchy with events
  • Larger class library
  • Better support for development tools
The .NET Framework consists of 3 main parts:
Programming languages:
  • C# (Pronounced C sharp)
  • Visual Basic (VB .NET)
  • J# (Pronounced J sharp)
Server technologies and client technologies:
  • ASP .NET (Active Server Pages)
  • Windows Forms (Windows desktop solutions)
  • Compact Framework (PDA / Mobile solutions)
Development environments:
  • Visual Studio .NET (VS .NET)
  • Visual Web Developer
This tutorial is about ASP.NET.

ASP.NET 2.0

ASP.NET 2.0 improves upon ASP.NET by adding support for several new features.
You can read more about the differences between ASP.NET 2.0 and ASP.NET in the next chapter of this tutorial.

ASP.NET 3.0

ASP.NET 3.0 is not a new version of ASP.NET. It's just the name for a new ASP.NET 2.0 framework library with support for Windows Presentation Foundation, Windows Communication Foundation, Windows Workflow Foundation; and Windows CardSpace.
ASP.NET 3.0 is not covered in this tutorial.

What is ASP.net

by ASP.NET · 0

ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to build dynamic web sites, web applications and web services. It was first released in January 2002 with version 1.0 of the .NET Framework, and is the successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime (CLR), allowing programmers to write ASP.NET code using any supported .NET language. The ASP.NET SOAP extension framework allows ASP.NET components to process SOAP messages.