Cross-Language Demo Demonstrates mixing C# and VB.NET code C# Class CSDemoClass.cs VB.NET Class 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
Network Managed Process ASP.NET Hosting the.NET Framework CLR Web form and custom application objects Request and post-back form information HTML representation of application UI Web Server Browser-Client ASP.NET in Context
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 Language="C#" Inherits=“TimePage" Src=“Time.cs" %> Time Page The time is
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 <asp:Calendar id="calendar" runat="server"> <asp:Button id="button" Text=“Submit" runat="server">...
Web Controls Example
XML Web Services Small, re-usable application components shared over the Web as services XML data representation HTTP transport protocol SOAP (Simple Object Access Protocol) RPC (Remote Procedure Call) standard
Network Managed Process ASP.NET Hosting the.NET Framework CLR XML Web Service objects SOAP Method Request SOAP Method Response Web Server Service-Client XML Web Services
Why use XML Web Services? Faster Development Use any.NET language XML naturally separates data from view “.NET My Services” provides core functions (user authentication, etc.) Greater Reliability Harness all the benefits of the CLR Integration Built off XML and SOAP
References Clark, Jason,.NET Tutorials, 2001 (Accessible at Microsoft Corporation, Microsoft.NET,