1 / 19

Cross-Language Demo

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() {

celine
Download Presentation

Cross-Language Demo

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Cross-Language Demo • Demonstrates mixing C# and VB.NET code • C# Class • CSDemoClass.cs • VB.NET Class • VBDemoClass.vb • “Main” class (C#) • Demo.cs

  2. CSDemoClass.cs using System; namespace CSDemo { public class CSDemoClass { … protected String getDateTime(){ return DateTime.Now.ToString(); } } }

  3. VBDemoClass.vb Public Class VBDemoClass Public Sub ShowTime(ByVal time as String) MsgBox(time, MsgBoxStyle.Information, “VB MsgBox”) End Sub End Class

  4. 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); } } }

  5. Cross-Language Example

  6. Using .NET Jiunwei Chen

  7. 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

  8. Managed Process ASP.NET Hosting the .NET Framework CLR Web form and custom application objects ASP.NET in Context Web Server Network Browser-Client Request and post-back form information HTML representation of application UI

  9. 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

  10. 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>

  11. Time.cs using System; using System.Web.UI; public class TimePage:Page{ protected void OutputTime(){ Response.Write( DateTime.Now.ToString(“T")); } }

  12. Time Example

  13. 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

  14. 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> ...

  15. Web Controls Example

  16. 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

  17. Managed Process ASP.NET Hosting the .NET Framework CLR XML Web Service objects XML Web Services Web Server Network Service-Client SOAP MethodRequest SOAP MethodResponse

  18. 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

  19. References • Clark, Jason, .NET Tutorials, 2001 (Accessible at www.devhood.com) • Microsoft Corporation, Microsoft.NET, http://www.microsoft.com/net/, 2002

More Related