Basics

Exlr Leverage the use of components when you write a console application that eventually becomes an ASP.NET application. When implementing your application functionality, encapsulate logical units of code behind methods in the classes that make up the component. If you program in this way, you will be able to reuse the code when migrating to a new user interface (Windows application or ASP.NET application). Also, if you put your code into components, you will be able to share these components with future or existing applications.

You will typically not choose to write console applications if you build a production application. There are cases in which you would choose a console application. Some examples of useful console-type applications include testing out programming syntax, building quick test harnesses, building administrative applications, or building debugging tools.

Untitled - Notepad

File Edit Format Help jsjxi

Import Namespace-'System" <HTML> <HEAD>

^SCRIPT LANGUAGE-'C#" RUNAT="Seiver"3

public static String GetFormattedDate(char cChoice)[ string sReturn; switch (cCholce.ToString()){ case "0".

sReturn = DateTlme.Now.ToSliortDateStrlngO; break;

case "2"

sReturn = DateTlme Now.ToShortTimeStringO; break, sReturn - DateTime.Now.DayOfVVeek.ToStringO, break;

sReturn = DateTime.Now.ToStringO; break;

default:

-Q Paste the GetFormattedDate function into the <SCRIPT>

section of the ASP.NET Web Page-

■ Scroll down the page to view the

SubmitBtn_Click function in the page, which calls the

GetFormattedDate function.

■ A Submit button calls the SubmitBtn_Click function.

0 Save the file and request from the Web server.

Q Click the Submit button.

■ The date appears in the format selected.

0 Save the file and request from the Web server.

Q Click the Submit button.

■ The date appears in the format selected.

Was this article helpful?

0 0

Post a comment