0% found this document useful (0 votes)
16 views7 pages

Chapter 4

Control arrays allow efficient manipulation of multiple controls at once. Debugging identifies and removes errors from code. HelpProviders integrate help systems into applications. ASP.NET is a web development platform that uses .NET framework classes for robust web applications across devices using HTTP.

Uploaded by

bayisadamisse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views7 pages

Chapter 4

Control arrays allow efficient manipulation of multiple controls at once. Debugging identifies and removes errors from code. HelpProviders integrate help systems into applications. ASP.NET is a web development platform that uses .NET framework classes for robust web applications across devices using HTTP.

Uploaded by

bayisadamisse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Chapter Four Control arrays such as these can be extremely useful,

Advanced Programming with event driven particularly if you need to manipulate a lot of controls all at
the same time.
4.1.Debugging Your Applications
Sample code
Debugging is the process of running our code step by step in a
debugger and identifying, analyzing, and removing errors (also
known as “bugs”) from our code.

While the compiler generally points to the syntax-related errors


and helps us fix them, logical errors aren’t that straightforward.
This is when we need to figure out why our code is not working,
and although talking to a rubber duck about it does sound more
fun, it’s more efficient to use a debugging tool.

4.2. Control Arrays

Control arrays are a distinctive feature of C# and Visual Basic


that brings efficiency and power to the language. You can use
them to create a common event procedure that's shared among
To select od deselect all check boxes using one time click,
all the controls in the control array. You also can use them to
it’s better to use control array like the following:
add and remove controls and forms to your program
dynamically at runtime.
Block of code to select all items once (for button Select All): 4.3.Adding Help to Your Programs

private void button3_Click(object sender, EventArgs e) Help system, enables the user to turn for assistance in times of
{
confusion.
// Initializing a list for control array called check
check = new CheckBox[] { checkBox1, checkBox2, checkBox3,
checkBox4 }; The .NET framework offers the Help class and the HelpProvider

//setting an action for each controls using loop statement


component to seamlessly integrate a Help system into our
for (int i = 0; i < check.Length; i++) applications. Basically, HelpProvider used to:
{
check[i].Checked = true;
} • Associate an HTML Help 1.x Help file (either a .chm
}
file, produced with the HTML Help Workshop, or a .htm
Block of code to deselect check boxes (Reset button): file) with your windows application.
private void button1_Click(object sender, EventArgs e) • Provide context-sensitive Help for controls on Windows
{
check = new CheckBox[] { checkBox1, checkBox2, checkBox3, Forms or specific controls.
checkBox4 };
• Additionally, the HelpProvider component can open a
for (int i = 0; i < check.Length; i++)
{
Help file to specific areas, such as the main page of a
check[i].Checked = false; table of contents, an index, or a search function
}
}
Additionally, the ToolTip Component can be used to provide
individual Help for controls on Windows Forms.

Here are some of the useful methods of HelpProvider.

• SetShowHelp() method specifies whether Help is


displayed for the specified control.
• SetHelpString() method specifies the Help string ASP.NET is a part of Microsoft .Net platform. ASP.NET
associated with the specified control. applications are compiled codes, written using the extensible
• SetHelpNavigator method specifies the Help command and reusable components or objects present in .Net framework.
to use when retrieving Help from the Help file for the These codes can use the entire hierarchy of classes in .Net
specified control. framework.
• SetHelpKeyword method specifies the keyword used to ASP.NET Web Forms Features
retrieve Help when the user invokes Help for the
ASP.NET is full of features and provides an awesome platform
specified control.
to create and develop web application. Here, we are discussing
• HelpNamspace property gets or sets a value specifying
these features of Web Forms.
the name of the Help file associated with this
HelpProvider. • Server Controls
4.4.Creating Programs for the Internet • Master Pages

ASP.NET (Active Server Pages) • Working with data


• Membership
ASP.NET is a web development platform, which provides a
• Client Script and Client Frameworks
programming model, a comprehensive software infrastructure
• Routing
and various services required to build up robust web applications
• State Management
for PC, as well as mobile devices. ASP.NET works on top of the
• Security
HTTP protocol, and uses the HTTP commands and policies to
• Performance
set a browser-to-server bilateral communication and
• Error Handling
cooperation.
Web Pages is one of many programming models for creating Web Forms comes with hundreds of different web controls and
ASP.NET web sites and web applications. Web Pages provides web components to build user-driven web sites with data access.
an easy way to combine HTML, CSS, and server code:
Web application
• Easy to learn, understand, and use
A Web application causes a Web server to send HTML code to
• Uses an SPA application model (Single Page Application)
a client. That code is displayed in a Web browser such as Internet
• Similar to PHP and Classic ASP
Explorer. When a user enters a URL string in the browser, an
• VB (Visual Basic) or C# (C sharp) scripting languages
HTTP request is sent to the Web server. The HTTP request
In addition, Web Pages applications are easily extendable with contains the filename that is requested along with additional
programmable helpers for databases, videos, graphics, social information such as a string identifying the client application,
networking and more. the languages that the client supports, and additional data
belonging to the request. The Web server returns an HTTP
What is Web Form?
response that contains HTML code, which is interpreted by the
Web Forms is one of the 3 programming models for creating Web browser to display text boxes, buttons, and lists to the user.
ASP.NET web sites and web applications. The other two
ASP.NET is a technology for dynamically creating Web pages
programming models are Web Pages and MVC (Model, View,
with server-side code. These Web pages can be developed with
Controller).
many similarities to client-side Windows programs.
Web Forms is the oldest ASP.NET programming model, with
Web Browser
event driven web pages written as a combination of HTML,
server controls, and server code. The purpose of a web browser is to read HTML documents and
compose them into visual or audible web pages. The browser
Web Forms are compiled and executed on the server, which
does not display the HTML tags, but uses the tags to interpret
generates the HTML that displays the web pages.
the content of the page.
Today we have the following major Web Browsers: shortly see that we can Web controls to this page to support
dynamic content.
• Internet Explorer (by Microsoft)
• Firefox (by Mozilla) With Default.aspx open and your project folder in the Solution
• Chrome (by Google) Explorer highlighted, hit the green triangular button at the top
• Safari (by Apple) toolbar or F5. You may get a window like debugging not
• Opera (by Opera from Norway) enabled. Go ahead and click OK.

Creating a Simple Web Page The default system browser opens and displays the application
running. Many web applications require users to create an
Create a new Web project by selecting File ➪ New ➪ Project
account before they can use certain features of the site. Visual
within Visual Studio. In the New Project dialog, select the
Web Developer automatically includes Login and Register
category Visual C# and the subcategory Web, and then select the
controls. Try logging in or create a new user.
ASP.NET Empty Web Application template. Name the project
EventRegistrationWeb. Close your browser and return to Visual Web Developer. For the
first user registered with the website, Visual Web developer
After creating the Web project, create a new Web page using the
automatically creates a SQL Server 2008 Express Edition
menu Project ➪ Add New Item, select the Web Form template,
database named ASPNETDB in the App_Data folder with
and name it Registration.aspx.
predesigned tables to support user accounts.
Pay attention to the directory where you store the project. The
To verify this, right--‐click on the App_Data folder in the
project should be in C:\Users\Public\...name it WebsiteExample,
Solution Explorer window and select Refresh Folder shown in
or any other name you like.
above right-side image. Expand App_Data by clicking on the
Visual Web developer creates a skeleton .aspx file named plus sign. You will see the database file ASPNETDB.MDF used
Default.aspx. This file contains only static code, but we will
by your website. By default, it includes 11 tables, providing A Simple HTML Document
functionality that extends beyond simple user accounts.
<!DOCTYPE html>
<html>
What is HTML?
<head>
<title>Page Title</title>
HTML is a format that tells a computer how to display a web </head>
page. The documents themselves are plain text files with special <body>
<h1>My First Heading</h1>
"tags" or codes that a web browser uses to interpret and display <p>My first paragraph. </p>
information on your computer screen. HTML is the standard </body>
</html>
markup language for creating Web pages.

• HTML stands for Hyper Text Markup Language Example Explained


• HTML describes the structure of Web pages using
• The <!DOCTYPE html> declaration defines this
markup
document to be HTML5
• HTML elements are the building blocks of HTML
• The <html> element is the root element of an HTML
pages
page
• HTML elements are represented by tags
• The <head> element contains meta information about
• HTML tags label pieces of content such as "heading",
the document
"paragraph", "table", and so on
• The <title> element specifies a title for the document
• Browsers do not display the HTML tags, but use them
• The <body> element contains the visible page content
to render the content of the page
• The <h1> element defines a large heading
• The <p> element defines a paragraph
HTML Tags Ordered Lists

HTML tags are element names surrounded by angle brackets: An ordered list is also a list of items. The list items are marked
with numbers. An ordered list starts with the <ol> tag. Each list
<tagname>content goes here...</tagname>
item starts with the <li> tag.
• HTML tags normally come in pairs like <p> and </p>
Inside a list item you can put paragraphs, line breaks, images,
• The first tag in a pair is the start tag, the second tag is
links, other lists, etc.
the end tag
• The end tag is written like the start tag, but with a HTML Links
forward slash inserted before the tag name
HTML uses the <a> anchor tag to create a link to another
The start tag is also called the opening tag, and the end tag the document or web page.
closing tag.
The Anchor Tag and the Href Attribute
Headings: Headings are defined with the <h1> to <h6> tags.
An anchor can point to any resource on the Web: an HTML
<h1> defines the largest heading while <h6> defines the
page, an image, a sound file, a movie, etc. The syntax of creating
smallest.
an anchor:
HTML Lists: HTML provides a simple way to show unordered
<a href="url">Text to be displayed</a>
lists (bullet lists) or ordered lists (numbered lists).
The <a> tag is used to create an anchor to link from, the href
Unordered Lists: An unordered list is a list of items marked
attribute is used to tell the address of the document or page we
with bullets (typically small black circles). An unordered list
are linking to, and the words between the open and close of the
starts with the <ul> tag. Each list item starts with the <li> tag.
anchor tag will be displayed as a hyperlink.

You might also like