Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Cross-Language Demo
Demonstrates mixing C# and VB.NET code
C# Class
VB.NET Class
CSDemoClass.cs
VBDemoClass.vb
“Main” class (C#)
Demo.cs
CSDemoClass.cs
using System;
namespace CSDemo {
public class CSDemoClass {
…
protected String getDateTime(){
return DateTime.Now.ToString();
}
}
}
VBDemoClass.vb
Public Class VBDemoClass
Public Sub ShowTime(ByVal time as String)
MsgBox(time, MsgBoxStyle.Information,
“VB MsgBox”)
End Sub
End Class
Demo.cs
using System;
using CSDemo;
using VBDemo;
namespace Demo {
class Demo {
static void Main(string[] args) {
String date;
CSDemoClass csApp = new CSDemoClass();
VBDemoClass vbApp = new VBDemoClass();
}
}
}
date = csApp.getTime();
vbApp.ShowTime(date);
Cross-Language Example
Using .NET
Jiunwei Chen
ASP.NET
Evolution of ASP (Active Server Pages)
Traditional web scripting language
Features
Use any .NET language (C#, VB, COBOL, etc)
Compiled and executed in native machine code
Allows for code-behind
Objected-oriented web development environment
Web Forms and Web Services
Browser-Client
ASP.NET in Context
Network
Managed Process
Request and post-back
form information
ASP.NET
Web form
and custom
application
objects
HTML representation
of application UI
Hosting the .NET
Framework CLR
Code Behind
Separation of the HTML and the code
Markup resides in an .ASPX file
Code lies in a C# (.CS) file or managed assembly
(.DLL)
ASP.NET
Class is derived from System.Web.UI.Page
HTML is generated and sent to the browser
Time.aspx
<% @Page Language="C#"
Inherits=“TimePage" Src=“Time.cs" %>
<html>
<body>
<TITLE>Time Page</TITLE>
<H1 align="center">
The time is <% OutputTime();%>
</H1>
</body>
</html>
Time.cs
using System;
using System.Web.UI;
public class TimePage:Page{
protected void OutputTime(){
Response.Write(
DateTime.Now.ToString(“T"));
}
}
Time Example
Web Forms
Core of ASP.NET
Separates interface from code logic (View /
Model)
ASP.NET detects browser and chooses rendering
Server-side controls
Can use visual tools to layout controls
Similar to VB, JavaBeans, WebObjects
WebControls.aspx
<% @Page Language="C#" Inherits="DatePage" … %>
<html>
...
<Form method="post" runat="server">
...
<asp:Calendar
id="calendar" runat="server">
</asp:Calendar>
<asp:TextBox id="date"
runat="server"/><br>
<asp:Button id="button"
Text=“Submit"
runat="server"></asp:Button>
...
Web Controls Example
XML Web Services
Small, re-usable application components
shared over the Web as services
XML
HTTP
data representation
transport protocol
SOAP (Simple Object Access Protocol)
RPC (Remote Procedure Call) standard
Service-Client
XML Web Services
Network
Managed Process
SOAP Method
Request
XML Web
Service
objects
SOAP Method
Response
ASP.NET
Hosting the .NET
Framework CLR
Why use XML Web Services?
Faster Development
Greater Reliability
Use any .NET language
XML naturally separates data from view
“.NET My Services” provides core functions (user
authentication, etc.)
Harness all the benefits of the CLR
Integration
Built off XML and SOAP
References
Clark, Jason, .NET Tutorials, 2001
(Accessible at www.devhood.com)
Microsoft Corporation, Microsoft.NET,
http://www.microsoft.com/net/, 2002