C# Note
C# Note
C# Note
The direct manipulation of graphical icons, such as buttons, scroll bars, windows, tabs, menus, cursors,
and the mouse pointing device, is becoming the standard for user-centered design in software
application programming. Graphical user interfaces (GUIs) allow users to operate computers and other
electronic devices intuitively. Many current graphical user interfaces have a touchscreen and voice-
command feature.
C# has all the features of any powerful, modern language. In C#, the most rapid and convenient way to
create your user interface is to do so visually, using the Windows Forms Designer and Toolbox. Windows
Forms controls are reusable components that encapsulate user interface functionality and are used in
client side Windows based applications.
Graphical User Interface makes use of visual elements mostly. These elements define the
appearance of the GUI. Some of these are described in detail as follows:
Window
This is the element that displays the information on the screen. It is very easy to manipulate a
window. It can be opened or closed with the click of an icon. Moreover, it can be moved to any
area by dragging it around. In a multitasking environment, multiple windows can be open at the
same time, all of them performing different tasks.
There are multiple types of windows in a graphical user interface, such as container window,
browser window, text terminal window, child window, message window etc.
Menu
A menu contains a list of choices and it allows users to select one from them. A menu bar is
displayed horizontally across the screen such as pull-down menu. When any option is clicked in
this menu, then the pull-down menu appears.
Another type of menu is the context menu that appears only when the user performs a specific
action. An example of this is pressing the right mouse button. When this is done, a menu will
appear under the cursor.
Icons
Files, programs, web pages etc. can be represented using a small picture in a graphical user
interface. This picture is known as an icon. Using an icon is a fast way to open documents, run
programs etc. because clicking on them yields instant access.
Controls
Information in an application can be directly read or influenced using the graphical control
elements. These are also known as widgets. Normally, widgets are used to display lists of similar
items, navigate the system using links, tabs etc. and manipulating data using check boxes, radio
buttons etc.
A control is a component on a form used to display information or accept user input. The Control class
provides the base functionality for all controls that are displayed on a Form.
You can use this.Controls collection to enumerate through all the controls
We can use Visual Studio to create ASP.NET Web Forms. It is an IDE (Integrated Development
Environment) that allows us to drag and drop server controls to the web forms. It also allows us
to set properties, events and methods for the controls. To write business logic, we can choose any
.NET language like: Visual Basic or Visual C#.
Web Forms are made up of two components: the visual portion (the ASPX file), and the code
behind the form, which resides in a separate class file.
The main purpose of Web Forms is to overcome the limitations of ASP and separate view from the
application logic.
ASP.NET provides various controls like: server controls and HTML controls for the Web Forms. We have
tables all these controls below.
Server Controls
The following table contains the server-side controls for the Web Forms.
HTML Controls
These controls render by the browser. We can also make HTML controls as server control. we
will discuss about this in further our tutorial.
Controls Description
Name
Button It is used to create HTML button.
Reset Resets all other HTML form elements on a form to a default value
Button
Submit Automatically POSTs the form data to the specified page listed in the Action
Button attribute in the FORM tag
Text Field Gives the user an input area on an HTML form
Text Area Used for multi-line input on an HTML form
File Field Places a text field and a Browse button on a form and allows the user to select a
file name from their local machine when the Browse button is clicked
Password An input area on an HTML form, although any characters typed into this field
Field are displayed as asterisks
CheckBox Gives the user a check box that they can select or clear
Radio Used two or more to a form, and allows the user to choose one of the controls
Button
Table Allows you to present information in a tabular format
Image Displays an image on an HTML form
ListBox Displays a list of items to the user. You can set the size from two or more to
specify how many items you wish show. If there are more items than will fit
within this limit, a scroll bar is automatically added to this control.
Dropdown Displays a list of items to the user, but only one item at a time will appear. The
user can click a down arrow from the side of this control and a list of items will
be displayed.
Horizontal Displays a horizontal line across the HTML page
Rule
Server Controls
Master Pages
Working with data
Membership
Client Script and Client Frameworks
Routing
State Management
Security
Performance
Error Handling
Server Controls
Web Forms provides rich set of server controls. These controls are objects that run when the page
is requested and render markup to the browser. Some Web server controls are similar to familiar
HTML elements, such as buttons and text boxes. It also provides controls that we can use to
connect to data sources and display data.
Master Pages
It allowsus to create a consistent layout for the pages in our application. This page defines the look
and feel and standard behavior that we want for all of the pages in our application. When users
request the content pages, they merge with the master page to produce output that combines the
layout of the master page with the content from the content page.
Working with Data
In an ASP.NET Web Forms application, we use data-bound controls to automate the presentation
or input of data in web page UI elements such as tables and text boxes and drop-down lists.
Membership
Project's Account folder contains the files that implement the various parts of membership:
registering, logging in, changing a password, and authorizing access. Additionally, ASP.NET
Web Forms supports OAuth and OpenID. These authentication enhancements allow users to log
into your site using existing credentials, from such accounts as Facebook, Twitter and Google.
Routing
We can configure URL routing of our application. A request URL is simply the URL a user
enters into their browser to find a page on our web site. We use routing to define URLs that are
semantically meaningful to users and that can help with search-engine optimization (SEO).
State Management
ASP.NET Web Forms includes several options that help you preserve data on both a per-page
basis and an application-wide basis.
Security
Performance
Web Forms provides good performance and allows us to modify performance related to page and
server control processing, state management, data access, application configuration and loading,
and efficient coding practices.
Debugging and Error Handling
We can diagnose problems that occur in our Web Forms application. Debugging and error
handling are well supported within ASP.NET Web Forms so that our applications compile and
run effectively.