Summary - ASP.net
Summary - ASP.net
NET
Framework Overview
A framework is software that integrates multiple technologies for application
development.
.NET Framework:
Components:
1. BCL (Base Class Library):
Components of CLR:
Summary - ASP.NET 1
Common Language Specification (CLS): Unifies language rules
across .NET languages.
Key Notes
BCL provides foundational libraries for development.
Component Purpose
Steps:
1. Create a New Project:
Select ASP.NET Web Application and specify the project name and
location.
4. Write Code:
Summary - ASP.NET 2
Use the <% %> syntax for ASP.NET-specific code in the Web Form.
Output:
After following these steps, you can run the project to see your application in
action.
ASP.NET Controls
Controls are used to create user interfaces. They allow users to interact with the
application.
Types of Controls:
1. HTML Controls:
Example:
2. Server Controls:
Syntax:
Summary - ASP.NET 3
<asp:Button ID="Button1" runat="server" Text="Submit" /
>
1. DropDownList:
Example:
2. ListBox:
Example:
3. RadioButtonList:
Example:
Summary - ASP.NET 4
<asp:ListItem>Female</asp:ListItem>
</asp:RadioButtonList>
4. CheckBoxList:
Example:
5. BulletedList:
Example:
Table Controls
Used to structure data into rows and columns.
Example:
Key Notes
HTML Controls: Basic UI elements enhanced for server interaction.
Summary - ASP.NET 5
Server Controls: Rich features with built-in server-side functionality.
1. Response.Redirect
Redirects users to a new page (can be on the same server or an external
server).
Syntax:
Response.Redirect("PageName.aspx");
Example:
Redirecting to another page:
Response.Redirect("HomePage.aspx");
2. Server.Transfer
Transfers users to another page on the same server without updating the
browser’s history or address bar.
Syntax:
Server.Transfer("PageName.aspx");
3. Cross-Page PostBack
Allows posting form data to another page.
Useful when you want to send data without using session or query strings.
Example:
Button1.PostBackUrl = "TargetPage.aspx";
4. Hyperlink Control
Navigates to another page using a clickable link.
Summary - ASP.NET 6
Example:
Master Pages
Master Pages define a consistent layout for a website. They act as templates for
web pages, ensuring a uniform design.
Features:
1. Consistent Layout:
Common elements like headers, footers, and navigation menus are shared
across pages.
2. Content Placeholders:
State Management
State management refers to techniques for preserving user data across page
requests.
Summary - ASP.NET 7
1. Client-Side State Management:
Techniques:
ViewState:
Example:
ViewState["Key"] = "Value";
TextBox1.Text = ViewState["Key"].ToString();
Cookies:
Example:
Response.Cookies["UserName"].Value = "John";
Hidden Fields:
Example:
Query Strings:
Example:
Response.Redirect("TargetPage.aspx?Name=John");
Techniques:
Session State:
Example:
Session["UserName"] = "John";
Application State:
Summary - ASP.NET 8
Example:
Application["AppName"] = "MyWebsite";
Example:
Key Notes
Navigation Techniques:
Master Pages:
State Management:
1. Introduction to ADO.NET
ADO.NET stands for ActiveX Data Objects for .NET.
Example:
Summary - ASP.NET 9
2. Command:
Example:
3. DataReader:
Example:
4. DataAdapter:
Example:
5. DataSet:
Example:
Summary - ASP.NET 10
DataTable Represents a single table inside a DataSet .
3. Workflow of ADO.NET
1. Open a connection to the database using SqlConnection .
Example:
2. Repeater:
Example:
3. DropDownList:
Example:
Summary - ASP.NET 11
<asp:DropDownList ID="DropDownList1" runat="server" Dat
aTextField="Name" DataValueField="ID"></asp:DropDownLis
t>
4. DataList:
Example:
5. DetailsView:
Example:
Summary - ASP.NET 12
Example:
Example:
try {
connection.Open();
} catch (SqlException ex) {
Console.WriteLine(ex.Message);
} finally {
connection.Close();
}
2. Security:
Key Notes
Data-Bound Controls make it easy to present data from a database.
Always prioritize security and proper error handling when working with
databases.
Summary - ASP.NET 13