















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
















HTML Server Controls: HTML server controls in classic ASP.NET provide properties and methods that ease the migration from classic ASP to ASP.NET pages. They closely resemble HTML elements and offer familiar attributes. However, some differences exist between HTML server control attributes and HTML element attributes. Abstracted Model: HTML server controls map closely to HTML elements. They provide an abstraction over HTML and are designed to mimic HTML elements, making it simpler for developers transitioning from classic ASP. Single Control vs. Separate Controls: For example, in HTML, a single tag can serve both list and dropdown functionalities. In contrast, ASP.NET provides separate controls for this purpose, such as the ListBox and DropDownList controls.
ASP.NET Web Server Controls: ASP.NET web server controls have an abstracted model that doesn't directly map to HTML elements. Their attributes and functionalities may differ from HTML controls.
Abstracted Model: ASP.NET web server controls provide an abstraction over HTML and have a model that might not directly correspond to HTML elements. This abstraction allows for more powerful and flexible controls. Separate Controls: Unlike HTML, where a single control can serve multiple purposes, ASP.NET provides separate controls for specific functionalities. For example, ListBox and DropDownList controls serve distinct purposes. Standard Control Categories: ASP.NET standard controls can be categorized into three main types:
This creates a Calendar control named calEventDate for selecting dates.
ASP.NET provides a web server control, (^) , for the creation of HTML tables. This control is mapped to HTML (^) , (^) (table row), and (^) (table cell) elements. It is often used to build tables dynamically, especially when the content is not known at design time.
Dim T1 As New Table() Dim Tr As New TableRow() Dim Tc As New TableCell()
' Add the TableRow to the Table T1.Rows.Add(Tr)
' Add the TableCell to the TableRow Tr.Cells.Add(Tc)
In this example, a new Table^ control ( T1^ ), a TableRow^ ( Tr^ ), and a TableCell^ ( Tc^ ) are created. The TableRow^ is then added to the Table^ , and the TableCell^ is added to the TableRow (^). This is a simple example, and you can dynamically add more rows and cells in a similar manner.
Keep in mind that this is a server-side approach, and you can perform these operations in the code-behind file ( .aspx.vb^ ).
' Create a new Table Dim myTable As New Table() myTable.ID = "myTableId"
' Add the table to the form form1.Controls.Add(myTable)
' Create rows and cells dynamically For i As Integer = 1 To 3 Dim row As New TableRow()
For j As Integer = 1 To 3 Dim cell As New TableCell() cell.Text = $"Row {i}, Cell {j}" row.Cells.Add(cell) Next
' Add the row to the table myTable.Rows.Add(row) Next End Sub End Class
In this example, we create a simple with a border, and during the initial page load, we call the CreateDynamicTable function in the code-behind to dynamically add rows and cells to the table. Adjust the logic inside CreateDynamicTable as per your specific requirements.
Purpose: The Label control in
ASP.NET serves the purpose of displaying static text on a webpage. It is commonly used for presenting non-editable content such as validation messages or informational text.
Usage:
Display static text on the webpage. Text content can be specified either in the markup or programmatically at runtime. Non-editable by users during runtime.
Syntax:
Purpose: The LinkButton control resembles an HTML hyperlink but functions like a button. It can execute code on its click event.
Properties:
Example:
Partial Class LinkB Inherits System.Web.UI.Page Protected Sub Link_Click (ByVal sender As Object, ByVal e As Sy ' Code to execute on link button click End Sub End Class
Purpose: The Button control creates a push button on a web form, which can function as either a submit button or a command button.
Properties:
Example:
Partial Class Content Inherits System.Web.UI.Page Protected Sub btnA_Command (ByVal sender As Object, ByVal e As ' Code to execute based on the command button clicked End Sub End Class
Purpose: The ImageButton control in ASP.NET is used to display a clickable image on a webpage. It allows users to interact with the webpage by clicking on the image. The control supports both click and command events similar to the Button control.
Usage:
Display a clickable image on the webpage. Supports both click and command events for additional functionality.
Properties:
Example:
End Sub End Class
Purpose: The CheckBox control is a web server control that allows users to switch between yes or no, or true or false options. It is ideal for providing multiple options to the user.
Properties:
Events:
CheckedChanged: Triggered when the checked state of the checkbox changes.
Example:
Example:
Type : Defines the data type (Integer, Double, Date). MinimumValue , MaximumValue : Sets the allowed range. Example:
OnServerValidate : Points to the server-side validation function. Example:
Purpose: Executed when the page is loaded.
Example:
protected void Page_Load(object sender, EventArgs e) { // Code to be executed when the page loads }
protected void gridView1_RowCommand(object sender, GridViewComma { if (e.CommandName == "Delete") { // Code to handle delete command } }
Purpose: Executed when the text in a TextBox control changes.
Example:
application and the underlying database, enabling you to easily retrieve, update, insert, or delete data.
Key Properties:
Example:
Suppose you have a table named Employees in your SQL Server database with columns EmployeeID , FirstName , LastName , and Salary. Here's how you can use the SqlDataSource control:
In this example:
ConnectionString is set to a connection string defined in the web.config file. SelectCommand retrieves all columns from the Employees table. DeleteCommand is specified to delete a record based on the^ EmployeeID parameter.
You can bind the (^) SqlDataSource to a data-bound control like (^) GridView for displaying data. Here's an example: