Professional Documents
Culture Documents
Ans.= ASP.NET includes data source controls that allow you to work with differen
t types of data sources such as a database,
an XML file, or a middle-tier business object. Data source controls connect to a
nd retrieve data from a data source and make
it available for other controls to bind to, without requiring code. They can als
o support modifying data.
A data source control, which is derived from the System.Web.UI.DataSourceControl
class, provides a single object that
you can define declaratively (in your web page) or programmatically (in your cod
e-behind file). It will manage internally
the connection to the data, its selection, and various options concerning its pr
esentation (such as paging and caching) so that
all you need to do is tell a UI control what data source to use and everything e
lse is taken care of. In some cases, the controls
also allow you to send changes to that data back to the source from which it ca
me. The entire life cycle of the query to and response
from the data source is encapsulated in this one control.
Many data source controls exist for accessing data from SQL Server, from ODBC or
OLE DB servers, from XML files, and from business objects.
They are divided into two groups: those representing sources of hierarchical dat
a (XML and Sitemap documents) and those representing flat
or table-based data (in business objects, databases, or through LINQ sources), w
ith members of both groups binding to UI objects
(such as DataList and GridView) in the same way and handling the plumbing for yo
u. This is in marked contract to ASP.NET 1.1 development,
where you had to work with the plumbing directly using the ADO.NET object model.
Properties=
Data source controls
SqlDataSource
hat returns SQL data,
Description
It represents a connection to an ADO.NET data provider t
DataBoundControl
HierarchicalDataBoundControl
The abstract class DataBoundControl is again inherited by two more abstract clas
ses:
ListControl
CompositeDataBoundControl
The controls capable of simple data binding are derived from the ListControl abs
tract class and these controls are:
BulletedList
CheckBoxList
DropDownList
ListBox
RadioButtonList
The controls capable of declarative data binding (a more complex data binding) a
re derived from the abstract class CompositeDataBoundControl.
These controls are:
DetailsView
FormView
GridView
RecordList
Q. Write five basic asp.net control?(basic control and basic event)
Ans.
the basic five controls available in ASP.NET.
1. Button Controls
ASP.NET provides three types of button control:
Button : It displays text within a rectangular area.
Link Button : It displays text that looks like a hyperlink.
Image Button : It displays an image.
When a user clicks a button, two events are raised: Click and Command.
2. Text Boxes and Labels
Text box controls are typically used to accept input from the user. A text box c
ontrol can accept one or more lines of
text depending upon the settings of the TextMode attribute.
Label controls provide an easy way to display text which can be changed from one
execution of a page to the next.
If you want to display text that does not change, you use the literal text.
3. Check Boxes and Radio Buttons
A check box displays a single option that the user can either check or uncheck a
nd radio buttons present a group of options
from which the user can select just one option.
To create a group of radio buttons, you specify the same name for the GroupName
attribute of each radio button in the group.
If more than one group is required in a single form, then specify a different g
roup name for each group.
If you want check box or radio button to be selected when the form is initially
Data Caching : Data caching means caching data from a data source. As long as th
e cache is not expired, a request for the data
will be fulfilled from the cache. When the cache is expired, fre
sh data is obtained by the data source and the cache
is refilled.
Object Caching : Object caching is caching the objects on a page, such as data-b
ound controls. The cached data is stored in server memory.
Class Caching : Web pages or web services are compiled into a page class in the
assembly, when run for the first time. Then the assembly is
cached in the server. Next time when a request is made for the p
age or service, the cached assembly is referred to.
When the source code is changed, the CLR recompiles the assembly
.
Configuration Caching : Application wide configuration information is stored in
a configuration file. Configuration caching stores the
configuration information in the server memory.
Q. Define response. Redirect
Ans. Response.Redirect
Response.Redirect() will send you to a new page, update the address bar and add
it to the Browser History. On your browser you can click back.
It redirects the request to some plain HTML pages on our server or to some other
web server.
It causes additional roundtrips to the server on each request.
It doesn t preserve Query String and Form Variables from the original request.
It enables to see the new redirected URL where it is redirected in the browser (
and be able to bookmark it if it s necessary).
Response. Redirect simply sends a message down to the (HTTP 302) browser.
Server.Transfer
Server.Transfer() does not change the address bar, we cannot hit back.One should
use Server.Transfer() when he/she doesn t want the user to see where he is going.
Sometime on a "loading" type page.
It transfers current page request to another .aspx page on the same server.
It preserves server resources and avoids the unnecessary roundtrips to the serve
r.
It preserves Query String and Form Variables (optionally).
It doesn t show the real URL where it redirects the request in the users Web Brows
er.
Server.Transfer happens without the browser knowing anything, the browser reques
t a page, but the server returns the content of another.
Q. What are the types of SQL command?
Ans.==
SQL commands are instructions, coded into SQL statements, which are used to comm
unicate with the database to perform specific tasks,
work, functions and queries with data.
SQL commands can be used not only for searching the database but also to perform
various other functions like, for example,
you can create tables, add data to tables, or modify data, drop the table, set
permissions for users. SQL commands are grouped
into four major categories depending on their functionality:
Data Definition Language (DDL) - These SQL commands are used for creating, modif
ying, and dropping the structure of database objects.
Data Source=yourdatabasename.mdb;"
ODBC Connection String
connetionString="Driver={Microsoft Access Driver (*.mdb)};
DBQ=yourdatabasename.mdb;"
You have to provide the necessary connection information to the Connection Strin
g attributes.
Q. ==What is web.net config file.
Ans. ==Web.config is the main settings and configuration file for an ASP.NET web
application. It is an XML document that resides in the
root directory of the site or application and contains data about how the web a
pplication will act. This information controls module loading,
security configuration, session state configuration, and application language an
d compilation settings. Web.config files can also contain
application specific items such as database connection strings.
Q. == How to establish a databases connection using ADO.net? (SQL connection cla
ss , SQL command class)
Ans. ==The Connection Object is a part of ADO.NET Data Provider and it is a uniq
ue session with the Data Source. The Connection Object
is Handling the part of physical communication between the C# application and th
e Data Source.
The Connection Object connect to the specified Data Source and open a connection
between the C# application and the Data Source,
depends on the parameter specified in the Connection String . When the connectio
n is established, SQL Commands will execute with the
help of the Connection Object and retrieve or manipulate data in the Data Sourc
e.
Once the Database activity is over , Connection should be closed and release the
Data Source resources .
If you have a named instance of SQL Server, you'll need to add that as well.
"Server=localhost\sqlexpress"
When the connection is established , SQL Commands will execute with the help of
the Connection Object and retrieve or manipulate
the data in the database. Once the Database activities is over , Connection shou
ld be closed and release the Data Source resources