Professional Documents
Culture Documents
NET
4. Where does the Web page belong in the .NET Framework class
hierarchy?
System.Web.UI.Page
12. Should validation (did the user enter a real date) occur server-
side or client-side? Why?
Client-side. This reduces an additional request to the server to validate
the users input.
23.What property must you set, and what method must you call in
your code, in order to bind the data from some data source to the
Repeater control?
You must set the DataSource property and call the DataBind method.
26. What tags do you need to add within the asp:datagrid tags to bind
columns manually?
Set AutoGenerateColumns Property to false on the datagrid tag
27.What tag do you use to add a hyperlink column to the DataGrid?
<asp:HyperLinkColumn>
28. What is the transport protocol you use to call a Web service?
SOAP is the preferred protocol.
31. Which property on a Combo Box do you set with a column name,
prior to setting the DataSource, to display data in the combo box?
DataTextField property
32. Which control would you use if you needed to make sure the
values in two different controls matched?
CompareValidator Control
33. True or False: To test a Web service you must create a windows
application or Web application to consume this service?
False, the webservice comes with a test page and it provides HTTP-
GET method to test.
<httpModules>
<remove name="Session” />
</httpModules>
38. What is the difference between a web service and a web site?
Web sites are pictures of data designed to be viewed in a browser. A
web service is designed to be accessed directly by another service or
software application. It is reusable pieces of software that interact
programmatically over the network.
42. Can aspx file contain more then one form marked runat=”Server”
No.
43. Is possible to see the code that asp.net generate from an aspx
file.
Yes. Enable debugging by including a <%@ page debug=”true” %>
directive in the aspx file or <compilation debug=”true”> statement in
web.config. then llok for the generated VB file in a sub directory
temporary asp.net files.
53. How do you create an aspx page that periodically refresh itself?
Most browers recognize the following
<meta http-equiv=”Refresh” content=”nn”>
58. What is the difference between Web User Control and Web
Custom Control?Custom Controls
Web custom controls are compiled components that run on the server
and that encapsulate user-interface and other related functionality into
reusable packages. They can include all the design-time features of
standard ASP.NET server controls, including full support for Visual
Studio design features such as the Properties window, the visual
designer, and the Toolbox.
There are several ways that you can create Web custom controls:
You can compile a control that combines the functionality of two or
more existing controls. For example, if you need a control that
encapsulates a button and a text box, you can create it by compiling
the existing controls together.
If an existing server control almost meets your requirements but lacks
some required features, you can customize the control by deriving from
it and overriding its properties, methods, and events.
If none of the existing Web server controls (or their combinations) meet
your requirements, you can create a custom control by deriving from
one of the base control classes. These classes provide all the basic
functionality of Web server controls, so you can focus on programming
the features you need.
If none of the existing ASP.NET server controls meet the specific
requirements of your applications, you can create either a Web user
control or a Web custom control that encapsulates the functionality you
need. The main difference between the two controls lies in ease of
creation vs. ease of use at design time.Web user controls are easy to
make, but they can be less convenient to use in advanced scenarios.
You develop Web user controls almost exactly the same way that you
develop Web Forms pages. Like Web Forms, user controls can be
created in the visual designer, they can be written with code separated
from the HTML, and they can handle execution events. However,
because Web user controls are compiled dynamically at run time they
cannot be added to the Toolbox, and they are represented by a simple
placeholder glyph when added to a page. This makes Web user
controls harder to use if you are accustomed to full Visual Studio .NET
design-time support, including the Properties window and Design view
previews. Also, the only way to share the user control between
applications is to put a separate copy in each application, which takes
more maintenance if you make changes to the control.
Web custom controls are compiled code, which makes them easier to
use but more difficult to create; Web custom controls must be authored
in code. Once you have created the control, however, you can add it to
the Toolbox and display it in a visual designer with full Properties
window support and all the other design-time features of ASP.NET
server controls. In addition, you can install a single copy of the Web
custom control in the global assembly cache and share it between
applications, which makes maintenance easier.
(Session/State)
59. Application and Session Events
The ASP.NET page framework provides ways for you to work with
events that can be raised when your application starts or stops or
when an individual user's session starts or stops:
a. Application events are raised for all requests to an application.
For example, Application_BeginRequest is raised when any
Web Forms page or XML Web service in your application is
requested. This event allows you to initialize resources that will
be used for each request to the application. A corresponding
event, Application_EndRequest, provides you with an
opportunity to close or otherwise dispose of resources used for
the request.
b. Session events are similar to application events (there is a
Session_OnStart and a Session_OnEnd event), but are raised
with each unique session within the application. A session begins
when a user requests a page for the first time from your
application and ends either when your application explicitly
closes the session or when the session times out.
You can create handlers for these types of events in the Global.asax file.
66. What are the disadvantages of view state / what are the benefits?
Automatic view-state management is a feature of server controls that
enables them to repopulate their property values on a round trip
(without you having to write any code). This feature does impact
performance; however, since a server control's view state is passed to
and from the server in a hidden form field. You should be aware of
when view state helps you and when it hinders your page's
performance.
67. When maintaining session through Sql server, what is the impact
of Read and Write operation on Session objects? will
performance degrade?
Maintaining state using database technology is a common practice
when storing user-specific information where the information store is
large. Database storage is particularly useful for maintaining long-term
state or state that must be preserved even if the server must be
restarted.
loginUrl="url"
protection="All|None|Encryption|Validation"
requireSSL="true|false"
slidingExpiration="true|false">
<credentials
passwordFormat="Clear|SHA1|MD5">
<user name="username"
password="password"/>
</credentials>
</forms>
<passport redirectUrl="internal"/>
</authentication>
75. What are validator? Name the Validation controls in asp.net? How
do u disable them? Will the asp.net validators run in server side
or client side? How do you do Client-side validation in .Net? How
to disable validator control by client side JavaScript?
A set of server controls included with ASP.NET that test user input in
HTML and Web server controls for programmer-defined requirements.
Validation controls perform input checking in server code. If the user is
working with a browser that supports DHTML, the validation controls
can also perform validation ("EnableClientScript" property set to
true/false) using client script.
The following validation controls are available in asp.net:
RequiredFieldValidator Control, CompareValidator Control,
RangeValidator Control, RegularExpressionValidator Control,
CustomValidator Control, ValidationSummary Control.
VaryByParam
Description
value
One version of page cached (only raw
none
GET)
n versions of page cached based on
*
query string and/or POST body
n versions of page cached based on
v1 value of v1 variable in query string or
POST body
n versions of page cached based on
v1;v2 value of v1 and v2 variables in query
string or POST body
83. Where would you use an IHttpModule, and what are the
limitations of any approach you might take in implementing one?
Can you edit data in the Repeater control? Which template must you
provide, in order to display data in a Repeater control? How can you
provide an alternating color scheme in a Repeater control? What
property must you set, and what method must you call in your code, in
order to bind the data from some data source to the Repeater control?
84. What is the use of web.config? Difference between
machine.config and Web.config?
ASP.NET configuration files are XML-based text files--each named
web.config--that can appear in any directory on an ASP.NET
Web application server. Each web.config file applies configuration
settings to the directory it is located in and to all
virtual child directories beneath it. Settings in child directories can
optionally override or modify settings specified in parent directories.
The root configuration file--
inNT\Microsoft.NET\Framework\<version>\config\machine.config--
provides default configuration settings for the entire machine. ASP.NET
configures IIS to prevent direct browser access to web.config files to
ensure that their values cannot become public (attempts to access
them will cause ASP.NET to return 403: Access
Forbidden).
At run time ASP.NET uses these web.config configuration files to
hierarchically compute a unique collection of settings for
each incoming URL target request (these settings are calculated only
once and then cached across subsequent requests; ASP.NET
automatically watches for file changes and will invalidate the cache if
any of the configuration files change).
86. What are the different modes for the sessionstates in the
web.config file?
Open
machine.config(C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\C
ONFIG) & add new extension under <httpHandlers> tag
<add verb="*" path="*.santhosh"
type="System.Web.UI.PageHandlerFactory"/>
(WEBSERVICE & REMOTING)
90.What is a WebService and what is the underlying protocol used in
it?Why Web Services?
95. What’s the attribute for web service method? What is the
namespace for creating web service?
[Web Method]
When the Web Form is compiled, ASP.NET parses the page and its
code, generates a new class dynamically, and then compiles the new
class. The dynamically generated class is derived from the ASP.NET
Page class, but is extended with controls, your code, and the static
HTML text in the .aspx file.
This new derived Page class becomes a single executable file that is
executed on the server whenever the Web Forms page is requested.
At run time, the Page class processes incoming requests and
responds by dynamically creating HTML and streaming it back to the
browser. If the page contains Web controls (as it typically would), the
derived Page class acts as container for the controls, and instances of
the controls are created at runtime and likewise render HTML text to
the stream.
In ASP, the page consisted of static HTML interspersed with
executable code. The ASP processor read the page, extracted and ran
only the code (interpreted, rather than compiled), and then fitted the
results back into the static HTML before sending the results to the
browser.
The Page class performs these stages each time the page is called;
that is, the page is initialized, processed, and disposed every time a
round trip to the server occurs.
101.Briefly explain how code behind works and contrast that using
the inline style.
State Management
Hidden Fields
You can store page-specific information in a hidden field on your page as
a way of maintaining the state of your page.
If you use hidden fields, it is best to store only small amounts of frequently
changed data on the client. ASP.NET provides the HtmlInputHidden
control, which offers hidden field functionality.
Note If you use hidden fields you must submit your pages to the server
using the HTTP POST method rather than requesting the page via the
page URL (the HTTP GET method).
The advantages of using hidden fields are:
No server resources are required. The hidden field is stored and read
from the page.
Broad support. Almost all browsers and client devices support forms with
hidden fields.
Simple implementation.
The disadvantages of using hidden fields are:
Security. The hidden field can be tampered with. The information in the
hidden field can be seen if the page output source is viewed directly,
creating a potential security issue.
Limited storage structure. The hidden field does not support rich
structures. Hidden fields offer a single value field in which to place
information. To store multiple values, you must implement delimited
strings and the code to parse those strings.
Performance. Because hidden fields are stored in the page itself, storing
large values can cause the page to slow down when users display it and
when they post it.
Cookies
Cookies are useful for storing small amounts of frequently changed
information on the client. The information is sent with the request to the
server.
The advantages of using cookies are:
No server resources are required. The cookie is stored on the client and
read by the server after a post.
Simplicity. The cookie is a lightweight, text-based structure with simple
key-value pairs.
Configurable expiration. The cookie can expire when the browser session
ends, or it can exist indefinitely on the client computer, subject to the
expiration rules on the client.
The disadvantages of using cookies are:
Limited size. Most browsers place a 4096-byte limit on the size of a
cookie or 8192 for new browers.
User-configured refusal. Some users disable their browser or client
device's ability to receive cookies, thereby limiting this functionality.
Security. Cookies are subject to tampering. Users can manipulate cookies
on their computer, which can potentially represent a security compromise
or cause the application dependent on the cookie to fail.
Durability. The durability of the cookie on a client computer is subject to
cookie expiration processes on the client and user intervention.
Creating and reading cookies, HttpResponse.Cookies and
HttpRequest.Cookies Property.
Query Strings
A query string is information appended to the end of a page's URL.
You can use a query string to submit data back to your page or to another
page through the URL. Query strings provide a simple but limited way of
maintaining some state information. For example, they are an easy way to
pass information from one page to another, such as passing a product
number to another page where it will be processed.
Note Query strings are a viable option only when a page is requested
via its URL. You cannot read a query string from a page that has been
submitted to the server.
The advantages of using query strings are:
No server resources required. The query string is contained in the HTTP
request for a specific URL.
Broad support. Almost all browsers and client devices support passing
values in a query string.
Simple implementation. ASP.NET provides full support for the query string
method, including methods of reading query strings using the
HttpRequest.Params property.
The disadvantages of using query strings are:
Security. The information in the query string is directly visible to the user
via the browser user interface. The query values are exposed to the
Internet via the URL so in some cases security may be an issue.
Limited capacity. Most browsers and client devices impose a 255-
character limit on URL length.
The difference between the Inherit and the Import keyword is that the
Import statement only brings in the definition of a set of functionality
but does not make use of it. The Inherits keyword is more dynamic. An
object that inherits certain functionality can also override and or extend
the parent functionality.
Intrinsic controls
List Bound controls
Rich controls
Validation control
Intrinsic controls
Text boxes Displays single line or multilane text box.
Checkbox Creates check box allows user to switch T or F
Radiobutton Creates a single Radio Button
Checkbox list creates a multi selection check box
Radiobuttonlist Creates a radio button list
Dropdown list Displays a drop down list allows to select a single
item
List box displays a single selection or multiselection
Button Creates a push button
Link button creates a hyperlink style button
Image button Display an Image Button
Hyperlink Displays a link that directs to another page.
Image Displays a web compatible image
Table Displays a table
Panel Provides a container for other control
Rich controls
Checkbox list
Radiobuttonlist
Property
Repeatcolumns used to assign the no. of colums to
be reapeted in
the direction
Repeatdirection
Item template
Alternatingitem template
Separator template
Selecteditem template
Edititem template Give editing capabilities
Header template
Footer template
Validation controls
The SQL server provider provides direct access to a SQL server using
a protocol called TDS(Tabular data system)
OLEDB provider-can be used with a sql server database, it will not
provide any performance enchancements.
CONNECTION OBJECT
A connection is opend implicitly when using a DataAdapter or explicity
by calling the open method on the connection
DATAADAPTER OBJECT
The dataadapter object is populated with the resultset of the sql query
statement.
FILL METHOD
The fill method acts as a bridge between the datasource and the
dataset. It loads the data in the DataAdapter into the dataset.
Command object
The command object use sql is sqlcommand and use with oledb is
oledbcommand.
We can call stored procedure using the command object. A shortcut
way of calling storedprocedure in MS SQL is using Exicute keyword.
Command type
The property of command object is command type. Used to define the
type of command being sent to the database. There are three
command types.
Property
Text default
Storedprocedure used to execute a database stored procedure,
pass parameters to the stored procedure using the parameters
collection.
Tabledircet used to provide a table name to the command object.
Methods
Parameter Object
Method add (arguments-name of the parameter,type,size)
Property direction (this can be Input, Output, Inputoutput)
110. DATAREADER
For quick and dirty means of accessing data source, data reader is
used. Data reader provides read only, forward only data. It can be
used to return a record set or execute action queries which do not
return any data. It hold one row in memory at a time opposed to
dataset. Using data set can be an issue when large tables are loaded
in memory. If multiple users accessing the same machine at the same
time serious memory drain. In such situation data reader should be
used.
115. CACHING
116. TRACING
Asp.net provide Tracing service for debugging purpose instead of
writing in response.write.
Trace.write or warn.write() are used to output debugging. They are two
types.
Page level applies to a single page using trace=true attribute on the
top level, output shown at the bottom of the page.
Application level it should be used in a trace section in the
configuration file at application root directory.
118.What is ASP.NET?
120.Directives
Directives are instructions to the compiler that tell it how the page
should be run.
eg. Page,Import
<Script runat=server>
Scripttag
runat parameter
value server
Post method:
we can’t pass querystring.
post method send the information as apart of HTTP headers.
Unlimited no of characters we can pass using Post method
122. How would you assess how many visitors you have on
a site? Which tools have you used to make this easier?
Ans: Using Hit counter we can count the no of users visited on our site
46:GridView Events
PageIndexchanged event
PageIndexChanging Event
Row CancelingEdit Event
Row CommandEvent
RowCreated Event
Row DataBOundEvent
Row Deleted Event
Roe Deleting Event
Row Editing Event
Row Updated Event
Row Updating Event
SelectedIndexChanging Event
SelectedIndexChanged Event
Sorted Event
Sorting Event