Professional Documents
Culture Documents
ASP.NET
What is .net architecture and its framework?
https://www.guru99.com/net-framework.html
practical 2 writeup
This is the top-most layer of the application where the user performs their activity. Let's take the
example of any application where the user needs to fill up a form. This form is nothing but the
Presentation Layer. In Windows applications Windows Forms are the Presentation Layer and in
web applications the web form belongs to the Presentation Layer. Basically the user's input
validation and rule processing is done in this layer.
The Presentation Layer contains pages like .aspx or Windows Forms where data is
presented to the user or input is taken from the user
ASP.NET 1
Print Friendly Yes No
Fixed-Width Layouts
allow a designer more direct control over how the page will look
Benefits
Drawbacks
Liquid Layouts
preferred by designers who have a lot of information to get across in as little space as
possible
Benefits
provide consistency
Drawbacks
can result in columns of text that are either too wide or too small
external CSS files ⇒ changes in one file will reflect on the whole website
ASP.NET 2
provides detailed attributes
body{
background-color: lightblue;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.content-wrapper{
padding: 10px 30px;
}
p{
text-align: justify;
}
h1{
text-align: center;
}
.highlight{
font-weight: 700;
color: forestgreen;
}
h1, h2{
font-weight: 400;
}
ul li{
list-style-type: square;
margin-bottom: 10px;
margin-left: 50px;
}
https://www.sitepoint.com/premium/books/front-end-development-with-asp-net-core-angular-and-
bootstrap/read/1/k36msnfm/
https://www.tutorialspoint.com/csharp/csharp_type_conversion.htm
Local Variables
ASP.NET 3
created when a function is called
created when an object of the class is created and destroyed when the object is destroyed
Class variables
created at the start of program execution and destroyed automatically when execution
ends.
Constants Variables
Read-Only Variables
readonly keyword
using System;
class Geeks {
// instance variable
int a = 80;
// static variable
static int b = 40;
// Constant variables
const float max = 50;
// readonly variables
readonly int k;
// constructor
public Geeks()
{
// initializing readonly
// variable k
this.k = 90;
}
// Main Method
public static void Main()
ASP.NET 4
{
// Creating object
Geeks obj = new Geeks();
9. How to create Classes & Objects in C#? Explain with suitable example.
https://www.geeksforgeeks.org/c-sharp-class-and-object/
https://www.javatpoint.com/c-sharp-jagged-array
11. What are the different methods through which we can navigate among webpages?
Response.Redirect
It maintains the history and previous page is available with the back button.
It redirects the user to a web page hosted on the same server or a different server.
It has an additional round trip to the server that makes it a bit slower.
Server.Transfer
It transfers a current page request to another .aspx page on the same server.
It preserves server resources and avoids the unnecessary roundtrips to the server.
There is no URL changes in the address bar in this case so the back button cannot be
used.
Server.Exceute
It is very similar to the server.execute method for navigation but it retains the control from
the source web page and returns to the original page after execution of the target page.
The PostbackUrl property of the button is set to the page where you want to do cross-page
posting.
ASP.NET 5
💡 The event is an encapsulated delegate. C# and .NET both support the events with the
delegates.
1. In C#, event handler will take the two parameters as input and return the void.
2. The first parameter of the Event is also known as the source, which will publish the object.
3. The publisher will decide when we have to raise the Event, and the subscriber will determine
what response we have to give.
5. Generally, we used the Event for the single user action like clicking on the button.
6. If the Event includes the multiple subscribers, then synchronously event handler invoked.
Syntax of Delegates
Example of Delegates
class Program1
{
// declare delegate
public delegate void PrintWord(int value);
ASP.NET 6
// or
// Print printDel = new Print(PrintNumber);
printDel(100000);
printDel(200);
printDel(10000);
printDel(200);
}
13. Write the suitable example to explain the concept of Exception Handling in C#.
try − A try block identifies a block of code for which particular exceptions is activated. It is
followed by one or more catch blocks.
finally − The finally block is used to execute a given set of statements, whether an
exception is thrown or not thrown. For example, if you open a file, it must be closed whether
an exception is raised or not.
throw − A program throws an exception when a problem shows up. This is done using a
throw keyword.
Exception Classes in C#
System.ArrayTypeMismatchException Handles
3 errors generated when type is mismatched with the
array type.
ASP.NET 7
generated during typecasting.
System.OutOfMemoryException Handles errors
7
generated from insufficient free memory.
Example
using System;
namespace UserDefinedException {
class TestTemperature {
static void Main(string[] args) {
Temperature temp = new Temperature();
try {
temp.showTemp();
} catch(TempIsZeroException e) {
Console.WriteLine("TempIsZeroException: {0}", e.Message);
}
Console.ReadKey();
}
}
}
public class TempIsZeroException: Exception {
public TempIsZeroException(string message): base(message) {
}
}
public class Temperature {
int temperature = 0;
if(temperature == 0) {
throw (new TempIsZeroException("Zero Temperature found"));
} else {
Console.WriteLine("Temperature: {0}", temperature);
}
}
}
i) Web.Config
benefits:
extensible and application specific information can be stored and retrieved easily
need not restart the web server when the settings are changed
You can use any standard text editor or XML parser to create and edit ASP.NET
configuration files.
ASP.NET 8
Database connections
Caching settings
Session States
Error Handling
Security
Machine.config File
.config files inside individual website directories provide more granular control.
Web.config file
Each and Every ASP.NET application has its own copy of configuration settings
stored in a file called Web.config.
each subdirectory can have a Web.config file that includes settings that are specific
to the files and folders that are contained within the subdirectory.
ii) Global.asax
optional
At run time, this file is parsed and compiled into a dynamically generated .NET Framework
class
iii) Masterpage
http://www-
db.deis.unibo.it/courses/TW/DOCS/w3schools/aspnet/aspnet_masterpages.asp.html#gsc.tab=0
ASP.NET 9
16. Explain the concept of User Control with execution steps.
https://www.educba.com/c-sharp-user-control/
https://classroom.google.com/u/0/c/NTM4ODAzODE1ODIx/m/NTAyMDQzNjI0NDAw/details
video - https://youtu.be/y60P5yPlAcM
theory - https://www.tutorialspoint.com/asp.net/asp.net_life_cycle.htm
💡 practical no 5 writeup -
https://classroom.google.com/u/0/c/NTM4ODAzODE1ODIx/m/NTAyMDQzNjI0NDAw/details
The view state property of a page is used to automatically pass the information of
controls from one page to the other.
The ‘Session’ object is used to store and retrieve specific values within a web page.
https://www.guru99.com/asp-net-session-management.html#:~:text=Session management is a
way,values within a web page.
preserve page
Features:
Retain the control value on a page without storing them in a user profile or session state.
Store page values and control properties that you set or define on a page.
Create a custom View State Provider to store the view page information in a SQL Server
Database or another database.
ASP.NET 10
What are the Data Objects that can be stored in the View State?
String
Boolean Value
Array Object
Hash Table
Advantages:
easy to use
flexible
server-independent
enhanced security
Disadvantages:
performance
security risk
no auto-track
Case 1
When you need to store or preserve data or control values between postbacks that are
non-default.
Case 2
When you need to store application data that is not specific to a page.
Set the EnableViewState attribute of a single control to false to disable View State for that
control.
TextBox1.EnableViewState=false;
ASP.NET 11
To disable the View State for an entire page, set the page directive's EnableViewState to
false as seen below:
The QueryString collection retrieves the values of the variables in the HTTP query string
and it is specified by the values following the ?
limited length
http://www.codingfusion.com/Post/Query-String-Example-in-Asp-Net
https://tutorialslink.com/Articles/Connected-and-Disconnected-architecture-in-Adonet/1679
Connected Disconnected
It is connection oriented. It is dis_connection oriented.
Datareader DataSet
connected can hold the data of single table disconnected can hold multiple tables of data
ASP.NET 12
Fundamentals
Connection parameters
Credentials
Optional parameters
Values can be specified in C# for each row that needs to be inserted into the database.
Select commands to specify which rows need to be deleted can be specified in C#.
SQL Command in c#
methods used:
credentials
Username – sa
Password – demo123
Step 1)
Step 2)
provide a location
Step 3)
ASP.NET 13
add a button from the toolbox
Step 4)
double click the form so that an event handler is added to the code for the button click
event.
Step 1)
execute the “select” statement against the database and fetch all the table rows
accordingly.
Step 2)
C# Update Database
Deleting Records
ASP.NET 14
Connecting Controls to Data
Step 1)
Step 2)
Step 3)
DataBindings->Text property
Step 4)
click on “Next”
Step 5)
ASP.NET 15
2. Go to the text property of TutorialID → click on the down arrow button →
demotbBinding Source option → Tutorial ID
3. Repeat the above steps for the Tutorial Name text box.
Step 6)
change the Binding Source property of the BindingNavigator to point to our Demotb
data source
C# DataGridView
Step 1)
Drag the DataGridView control from the toolbox to the Form in Visual Studio
Step 2)
https://www.geeksforgeeks.org/basic-crud-create-read-update-delete-in-asp-net-mvc-using-c-
sharp-and-entity-framework/
i) Grid View
ASP.NET 16
GridView is a control used to display data in tables on a web page. It displays data in
both rows and columns, where each column represents a field, and each row
represents a record.
GridView helps to perform key activities like Insert, Delete, Sorting, and Paging.
Properties of GridView
Name Description
represents the border width of a Web Control Server. The specified border
BorderWidth
width of a web server is negative.
sets the Cascading Style Sheets class rendered by the Web Server Control
CssClass
on the client.
helps you navigate quickly to the Web Server Control. It allows you to
AccessKey
specify the keyboard shortcut for web server control.
represents and sets the background color of the Web Server Control. By
BackColor
default, it sets the color to be empty to show that there is no property set.
sets the border color for the Web Server Control. It is inherited from the
BorderColor
WebControl base class.
is used to get the name of the control tag associated with the Web Server
TagName
Control.
A Width is a unit that represents the width of a Web Server. The width of the
Width
Web Server is a negative value.
Methods of GridView
Name Description
binds a data source that invokes a server control and child controls with an
DataBind
option to raise the DataBinding event.
used to search the current naming container for the specific server control
FindControl
with the specified id parameter.
method called immediately after a child control is removed from the controls
RemovedControl
collection of the control object.
InitializerPage initializes the page row displayed when the paging feature is enabled.
LoadViewState loads the previously saved view state of the GridView control.
method used to pass the interface for server control hierarchy to the web
OnBubbleEvent
server control.
Name Description
ASP.NET 17
helps to determine the index of a row.
https://www.c-sharpcorner.com/UploadFile/puranindia/repeater-controls-in-Asp-
Net/#:~:text=The Repeater control is used,Bind Controls are container controls.
https://sites.google.com/a/thiyagaraaj.com/ajax/ajax-architecture
registers and loads the Microsoft AJAX library to enable the AJAX features.
features
ScriptManagerProxy
we can have only single instance of the ScriptManager control in our webpage.
you can use a ScriptManagerProxy control to register the custom scripts or generate a
proxy for the webservice.
<asp:ScriptManager
AllowCustomErrorsRedirect="True|False"
AsyncPostBackErrorMessage="string"
EnableViewState="True|False"
ID="string"
LoadScriptsBeforeUI="True|False"
OnAsyncPostBackError="AsyncPostBackError event handler"
OnDataBinding="DataBinding event handler"
OnDisposed="Disposed event handler"
ASP.NET 18
SupportsPartialRendering="True|False"
Visible="True|False"
>
<AuthenticationService
Path="uri"
/>
<ProfileService
LoadProperties="string"
Path="uri"
/>
<RoleService
LoadRoles="True|False"
Path="uri"
/>
<Scripts>
<asp:ScriptReference
Assembly="string"
IgnoreScriptPath="True|False"
Name="string"
NotifyScriptLoaded="True|False"
Path="string"
ResourceUICultures="string"
ScriptMode="Auto|Debug|Inherit|Release"
/>
</Scripts>
<Services>
<asp:ServiceReference
InlineScript="True|False"
Path="string"
/>
</Services>
</asp:ScriptManager>
ContentTemplate
Triggers -
allows you to define certain triggers which will make the panel update its content.
send request Or post data to server without submitting the whole page so that is called
asynchronous
ASP.NET 19
4. write the code to check availability in CheckAvailability.aspx.cs file
The extender targets the page control with the specified ID and adds a new behavior to it.
The behavior is further configured using a few public properties
Prevents users from typing specific characters into a TextBox control. This
FilteredTextBoxExtender
extender control attaches to a TextBox control.
Enables content to be displayed, but prevents the user from interacting with
ModalPopupExtender the rest of the page. This extender control attaches to any Web server
control that can be used to open the modal window.
Displays a message inside a TextBox control when the text box does not
TextBoxWatermarkExtender
contain a text value. This extender control attaches to a TextBox control.
https://www.partech.nl/nl/publicaties/2021/05/basics-of-asp-net-core-ajax-control-toolkit#
32. What is Web Services? How to create & consume web services?
https://www.careerride.com/view/steps-to-create-and-consume-web-service-20921.aspx
A web service is a collection of open protocols and standards used for exchanging data
between applications or systems. Software applications written in various programming
languages and running on various platforms can use web services to exchange data over
computer networks like the Internet in a manner similar to inter-process communication on
a single computer. This interoperability (e.g., between Java and Python, or Windows and
Linux applications) is due to the use of open standards.
ASP.NET 20
33. What is IIS? How to install IIS on Windows? What are the steps to configure Asp.Net
website on IIS?
What is IIS?
accepts and responds to the client's computer requests and enables them to share and
deliver information
It hosts the application, websites, and other standard services needed by users
https://www.howtogeek.com/112455/how-to-install-iis-8-on-windows-8/
https://learn.microsoft.com/en-us/iis/application-frameworks/scenario-build-an-aspnet-
website-on-iis/configure-an-asp-net-website-on-iis
ASP.NET 21