Professional Documents
Culture Documents
ViewState:
Impersonation:
When a client requests a page, the request goes to IIS; the IIS
does the filtration and gives the control of page processing to the
respective engine.
So when we request for an .aspx page, the control is given to
aspnet engine. This engine starts the HTTP pipeline.
The engine creates an instance of HTTP Runtime class per
appdomain. Because each application is present with in
appdomain. The appdomain is hosted with in worker process.
The HTTP Runtime class picks an instance of HttpApplication
class from the internal pool.
The HttpApplication class checks the web.config file and calls the
respective handler to process the request.
The handler calls the process request method.
The first step in this method calls FrameworkInitialise () which
builds the control trees for the page.
Next the process request method makes the page to transit
several stages:
1) Initialization: the Page_Init event is fired, in this phase; a
control tree is established with all the static controls present on
the page. All these controls are initialized to their default values.
Viewstate is not available in this phase. The controls are referred
through their ID’s
2) Viewstate Loading: LoadViewState event is fired. After the
init event the controls can be reffered only through their ID’s. At
LoadViewState event the controls receive their first property:
Viewstate. The viewstate information that was persisted at
server in their last submission. Thus the controls will be loaded
with the viewstate information present at the server.
3) PostbackDataProcessing: When the form is posted (due to
autopostback or submit button) the current values for all the
controls that participate in viewstate will be posted to server
through form post data present in hidden field _VIEWSTATE. Thus
current values of all participating controls will be in postdata. The
IPostbackDataHandler is implemented for all the controls that
have posted the data. For all these controls the framework will
fire LoadPostData event which will update their state with the
current values from the postdata.
Page Loading: page_load event is fired. The objects will take
their real shape in this phase. Now the objects or controls can be
referred not only through their ID’s they can be referred through
relative reference as DOM model of page is been built. The
objects will get their client side properties like width, color etc.
PostbackChangeNotification: this occurs after all the controls
that implemented IPostbackDataHandler has been updated with
the current values from postdata. During this operation it will
check for all those controls which has implemented this interface
has actually been changed or remain same since the last
submission. It will flag a Boolean value based on the analysis; for
those controls whose value has been changed it flags true. The
framework will fire RaisePostBackChangeEvent for all those
controls whose state or value has been changed.
PostbackEventHandling: The object or control that caused the
post back will be handled in this phase (controls autopost back or
button click which caused postback). RaisePostbackEvent will be
fired on this control. In this event we will be having some logic to
be implemented.
PreRendering: the prerender phase is the last step where the
objects can be modified last. After this phase the objects cannot
be modified further. The viewstate is modified and saved for the
last time. No further changes can happen. PreRender event is
fired.
Viewstate Saving: SaveViewstate event is fired. In this phase
after all modifications to the objects are done; the current state
of all the controls are taken encoded in to base64 string and put
it in to hidden variable and sent along with the page.
PageRendering: Render event is fired on page, which in turn
fires render event on each control of the page to render their
HTML. The HTML of all these controls is collected by page and
send as a response to the client.
PageUnloading: all the objects which are created from page
initialization including the page object is disposed. All the server
resources has been released.
MSIL
The compiler translates the source code in to MSIL which is a
CPU-Independent set of instructions that can be effectively
converted to native code.
MSIL includes instructions for loading, storing, initializing, calling
methods on objects, instructions for arithmetic and logical
operations, control flow, direct memory access, exceptions and
other operations.
Before code can be run, MSIL must be converted to CPU-specific
code, by JIT compiler.
Thus the JIT compiler converts the MSIL to CPU-specific code.
The CLR supplies one or more JIT compilers for the computer
architecture it supports.
JIT compiler takes in to account the fact that some code might
never get called during execution. Rather than using time and
memory to convert all the MSIL to native code, it converts the
MSIL as needed during execution and stores the resulting native
code in cache such that is accessible for subsequent calls.
The loader creates and attaches a stub to each of the method
when it is loaded.
On initial call to the method, JIT compiler compiles MSIL of the
method to native code and modifies the stub to the location
address where this native code is stored.
Subsequent calls of the JIT- compiled method proceeds directly
to the native code
In .net we have 3 types of JIT compilers:
Pre – JIT: compiles entire source code in to native code at one
stretch
Ecno – JIT: compiles code part by part and freeing when
required.
Normal JIT: compiles only that part of code when called and
places in cache.
In all, the role of JIT compiler is to bring higher performance by
placing the once compiled code in cache, so that when a next
call is made to the same method/procedure it gets executed
faster
Source code -> MSIL by lang compiler (CPU – Independent
instructions)
MSIL -> native code by JIT compiler (CPU – Specific code).
Runtime supplies another mode of compilation called install-time
code generation. When using this install-time code generation
mode the entire assembly that is being installed is converted in
to native code.
As a part of compiling MSIL to native code, the code needs to
pass through verification process. The verification process tells
that the code is type safe.
ADO.Net Architecture:
DataRelation
Dataset
COM
Garbage Collection
Sessions
Remoting
Remoting
Views
Assemblies
CLR Architecture
Caching
HiddenField:
Application State:
Web.Config
PublisherPolicy
Different Timers
System.windows.forms.timers
System.timers.timer
System.threading.timers.
Authentication
The process of identifying and validating the user credentials
such as user name and password is called Authentication.
After the process of Authentication, the Authorization process
comes in to picture which is identifying the privileges for these
users. Authorization is a process of allowing an authenticated
user access to resources.
Asp.net provides Authentication through 3 providers:
Windows Authentication Module
Form Authentication Module
Passport Authentication Module
Custom Authentication
In web.config the mode is set to any one of these, the default is
windows. We can also set it to “None”. When the mode is set to
none we can allow custom authentication through application
code.
Asp.net has two authentication layers, since asp.net is not a
stand-alone it resides on the top of IIS; and all request moves
through this IIS to applications, the IIS can deny any request
even before the application knows about the request.
Windows Authentication Module provider relies on IIS in
authenticating the user credentials through any of it’s or
combination of its methods such as Anonymous, Basic, Digest,
and windows integrated methods.
An important use to windows authentication provider is to
implement Impersonation scheme
Windows authentication will avoid or remove authentication and
authorization issues from the application code. The application
just relies on IIS in authenticating the users and on NTFS for
authorization or privileges to the protected users. Impersonation
means it gives a token either for a valid or invalid user. In case of
Invalid user if anonymous is selected it gives IUSR_machine
account
If the user credentials are validated and authenticated an
authenticated token is passed to the application along with
request, if the credentials are not authenticated an
unauthenticated token is sent to the application along with the
request. In either case the application will impersonates the
token it has received if anonymous access is allowed. It will use
IUSR_Machine account if anonymous access is allowed. If
anonymous access is not allowed then the requests are made
taking user credentials in to consideration.
Anonymous users are those having an unauthenticated token.
When IIS receives a request from these users, then the request is
served under the credential of <IUSR_Machine> who has a very
limited or restricted access.
Basic Authentication is one of the methods of authentication in
IIS. The user credentials which are collected at the time of login
are passed to IIS server when the user requests for an
application. The major drawback in this method is user
credentials are passed as plain text to the IIS server which is not
secured.
Digest Authentication works in the same manner, but the user
credentials are encrypted and send to the IIS server when the
user requests a page.
Integrated windows works in the same manner as Digest, here a
token is generated for the user credentials, and this token is
encrypted and sends to IIS server, it works only on Intranet. The
other two basic and Digest works on public net.
Form Authentication:
Passport Authentication:
Typed Dataset
Dispose Method
Constructors
Static Constructors
A Static Constructor is used to initialize a class, it is called only
once in its life time, it is called before the first instance is created
or any static members are referenced.
Static members does not have any access modifiers or any
parameters, it cannot be explicitly called.
Static constructors are not inherited.
One cannot predict when this constructor will be called or order
of static constructors gets called.
Private Constructors
Destructors in c#
DataReader
DataAdapter
DataGrid Control
Access Specifiers
Pagination in Datagrid
DataList Control
Repeater Control
Repeater is a basic templated data – bound list control.
Repeater is the only control that allows developers to split html
tags across the templates. To begin with start the table tag in
header template, use its row tag in itemtemplate and end the
table tag in footer template.
This Html tags like table, or td, or <tr> should not have runat
attribute.
The designer window of the aspx page provides only limited
editing for the Repeater control, as this control allows incomplete
html tags in the template mean table tag is started in header
and ended in footer. Hence the template editing of this control is
done only in html view of the designer, it is not allowed or no
provision in the design view of the page bcos the designer
window always checks for the correctness of the html code.
Hence it is not allowed in designer window, it is done only in html
view of the design window.
Repeater has in-built editing or selection support. At bare
minimum itemtemplate needs to be specified to get data
displayed.
Repeater can be databound to itemtemplate and AlternatingItem
template through datasource property. But Header, Footer and
separator template are not databound.
If the datasource of the repeater control is set but has not
returned any rows, then Header and Footer template are
rendered on page, but if the datasource has returned null
reference than repeater control is not rendered.
Controls in the template may be bound to the datasource of the
Repeater control or to a separate datasource. Binding controls to
the Repeater control datasource ensures that all controls will
display the values from the same data row. The syntax for
binding the controls to Repeater control uses Databinder.Eval
(Container.DataItem) where container is the Repeater control
bcos it is the container for all the controls, so all the controls
uses the Repeater’s datasource, if you want to use any other
dataset than the container’s datasource than just say that
particular datasource name in place of Container. This might be
used if we want to display a row of data from the datasource
different from the Repeater control’s datasource.
Unlike datalist where we will use asp tables (not html tables) in
each template, we have property called “Extract Template Rows”
which is set to true to get all the rows in template to be
extracted in to single table, each template will have its own
table; but in Repeater control we can use html tables which can
be split across the templates, hence we don’t have “Extract
Template Rows” property here all the rows will be extracted in to
one table as it has only one table. We can’t split asp table across
the templates.
using System;
class bbb
{
public static void Main()
{
aaa a = new aaa();
bbb b = new bbb();
a.DSPLineClick += new DSPLineEventHandler(b.hello);
a.RaiseEvent();
}
DatagridTableStyle
SqlException class
This class gets created when data provider for Sql server
generates an error.
Sqlexception class contains atleast one instance of the sqlerror
object. The sqlerror objects are maintained through
sqlerrorcollection class.
Messages of different severity levels are seen ranging from 1 –
25. When the message severity level is 19 or less than
sqlconnection remains open, but when the severity level is 20 or
more the sqlconnection is closed. In any case the Sqlexception is
thrown from the method that executed the sqlcommand.
An error is a property of the Sqlexception class which gives the
count of sqlerror objects in the particular exception class. Each
sqlerror object gives detailed information about exception
generated by the data provider of the sql server.
Number is a property which gives the severity level of the error.
Procedure is a property that gives the name of the procedure
that generated the error
using System;
class aaa
{
public static void Main()
{
aaa a = new aaa();
a.abc();
}
public void abc()
{
try
{
pqr();
Console.WriteLine("Exception was Thrown");
}
catch
{
Console.WriteLine("Exception in abc");
}
}
}
catch
{
Console.WriteLine("Exception in pqr");
}
}
}
output: Exception in pqr
Exception was thrown
using System;
class aaa
{
public static void Main()
{
aaa a = new aaa();
a.abc();
}
public void abc()
{
try
{
pqr();
Console.WriteLine("Exception was Thrown");
}
catch
{
Console.WriteLine("Exception in abc");
}
}
}
finally
{
Console.WriteLine("Finally in pqr");
}
}
}
HttpContext Class
With every request the client makes, the server receives an
instance of HttpContext class.
This instance is exposed through the static property of this class
called “current”.
This object is sent with every request to the server. All the
classes which implements IHttpModule or IHttpHandler receives
a reference of HttpContext class with every request the client
makes. And this holds all the information for that request. As
every webpage is derived from page class and this base page
class implements the above interfaces; we will receive a
reference of HttpContext object with every request.
The HttpContext holds intrinsic objects like Request, Response,
Application, Cache, Server and Session etc.
All this properties hold references to their objects respectively
mean Application holds reference to the instance of
HttpApplicationState class and Request holds reference to
HttpRequest class etc.
In the code page we can directly use Application or Request or
Session etc objects directly bcos all these objects are given to us
through the instance of this HttpContext class.
We need not refer this objects with full qualify name as
HttpContext.Current.Application because we will refer the
namespace at top as system.web.
The instance of HttpApplicationState class is created when any
page in this application is requested for the first time. This
instance is reffered through Application property of the
HttpContext object.
The current user who made the request can be known through
User.Identity.Name. User is the property exposed by the context
object
Command Behavior
When an ExecuteReader method is called which belongs to
IDbcommand interface, we can use Command Behavior enum.
The Command Behavior.Close Connection closes the connection
object when the associated datareader is closed.
The Command Behavior.Default mean it is not applying any flag
it is as simple as calling ExecuteReader () which is another
overloaded method.
The Command Behavior.KeyInfo means it gives the column and
primary key information.
The Command Behavior.SingleRow means it returns only single
row.
The Command Behavior.SchemaOnly means it returns the
schema information or column information of the table.
The Command Behavior.SequenceAccess means when the
datarow holds a big stream of data where all of it might not be
useful; then instead of loading the entire row, we can only load
the stream of data that is useful specifying the start point and
number of bytes or characters to load through GetBytes () or
GetChars () methods. Once the respective data from the row is
loaded we can access it sequentially.
The Command Behavior.SingleResult means it gives only single
result set.
Thus Command Behavior is the enum which specifies the value
to be behaved by the associated datareader object while
executing ExecuteReader method.
Custom HttpHandlers
When a client requests a page, the request goes to IIS
webserver.
IIS communicates with .net framework through unmanaged ISAPI
extensions.
IIS based on file extension of the page requested, it assigns to
the respective engine process.
If the page requested was for .html then IIS will itself handle it.
If the page requested was for any asp.net related stuff like .aspx
or .asmx, it delegates the processing of request to asp.net
engine
If the page requested was for any asp stuff like .asp, it delegates
it to asp engine.
This delegation of jobs to other engine process has two
advantages a) it provides a nice division of labor and IIS can
concentrate only on its stuff, i.e serving static content to client b)
dynamic server side technologies or files are added to IIS in a
pluggable manner, if IIS was responsible for handling asp.net
pages rather than relying on external engine; in that case, each
time a new version of asp.net came out or file extensions are
changed then a new version of IIS would need to be created to
support this new extensions. With this delegation we can just
map the new extension to the corresponding engine process in
IIS metabase through Internet Service Manager.
When the request is routed from IIS to Asp.net engine, the
asp.net engine first examines the requested file extension and
then invokes the httphandler associated with that extension
whose job is to render the requested file’s markup
Technically asp.net engine can invoke either httphandler or
httphandlerfactory which returns an instance of httphandler
The Http handler receives the request processing call from
asp.net engine and process the request and returns the
appropriate mark up response to the IIS.
This mark up is served back to the client by IIS.
The Http handler actually receives an HttpContext object for the
current request. And it provides the response through this
context object as context.Response.write (<html> <b>
hi</b></html>).
We can write custom handlers to process the request of user
choice like .fm or .cs etc. So in order to process this request we
must create handlers and configure them in IIS and our
application.
To create a custom handler, take a library project, create a class,
this class should implement IHttpHandler. This interface actually
has one method and one property. The Method is
ProcessRequest (HttpContext obj) which process the request.
And a property IReusable which tells the current instance of the
handler can be used for further requests. If true it can be used
else no.
So once the custom handler is created we should first configure
to our application. In web.config under <HttpHandler> put the
statement like:
<add verb=”*” path=”*.cs” type= “../customhandler”/>
The type should include the path where this custom handler is
stored the dll path. Thus our application is configured to handle
the request.
Now IIS should be configured bcos when the request comes for
.cs IIS does not know for whom it should delegate this request.
So we will configure the IIS metabase through Internet Service
manager.
Add a new item, when a file extension .cs comes delegate this
request to asp.net engine.
So once the request comes to asp.net engine, it will check in the
web.config file of that application whether any handler is written
to handle this request. Thus request is finally handed over to the
custom handler which will process and gives the response
markup to IIS.
Thus the custom handler which are written by implementing
IHttpHandler must be configured to both IIS and Application
This will print yes, bcos the type of the object is the value it is
holding and which can be shown through the operator “is”. The
major difference between boxing and unboxing is in boxing the copy
of value is boxed, but in unboxing the value still refers to the same
instance.
Validation Controls:
validation server controls are a collection of controls that
validates an associated input server controls like textbox and
displays a custom message when validation fails
Each validation control plays a specific type of validation. For ex:
against a specific value by compare validator on a range of
values by RangeValidator etc.
We can collect all the error messages of validation controls on a
page in to ValidationSummary control.
We can also have user specific or custom validation through
custom validator control.
Validation occurs when button controls like button, linkbutton,
imagebutton is clicked. We can disable this validation from not
happening when this buttons are clicked by setting
“Causesvalidation” property to false. Usually validation does not
happen whenever page is posted back; for ex: if AutoPostBack
property for dropdown list is true then when the page is posted
back the validation does not happen.
Every Validation control share some basic validation properties
like a) controltovalidate, b) display, c) EnableClientScript,
d)Enabled, e)ErrorMessage, f)isvalid, and g) Text.
Display is the property which has three options None, Static,
Dynamic.
None is used when the error message is captured in to validation
summary control.
Static: every validation control when placed on the form will
occupy some space for the error message to be displayed. Even
when the input control passes also the space will be reserved by
the validation control on the form. If multiple validation controls
are present for input control then multiple spaces will be
reserved. As the space is reserved there is no change in the
static display of the page. Hence the static layout of the page is
not disturbed when error messages are displayed.
Dynamic: here validation controls does not reserve any space.
The space is taken dynamically; hence multiple validation
controls use the same space. As the space is allocated
dynamically the page layout might get disturbed if sufficient
space is not allocated for the validation control. Hence in case of
dynamic display the space for validation control should be given
to its max.
For a validation control we have two properties like ErrorMessage
and Text which is used when is: if validationsummary control is
used to display error messages then content written in
Errormessage property is used. If no validationsummary control
is used then the content written in the Text property is used to
display the error message. If no text is specified then the content
of ErrorMessage is taken and displayed.
Comparevalidator and Rangevalidator are the two validators that
perform typed comparisons. The datatypes that are supported
are specified in validationdatatype enum. This enum contains
types like: currency, date, double, integer, and string.
Comparevalidator: the compare validator is used to compare
two input controls through controltovalidate and
controltocompare properties.
Instead of comparing two input controls, Comparevalidator
control is also used to compare with a constant value. Specify
the value to compare by setting valuetocompare property with
the text.
The operator property is used to specify the type of comparison
to be performed on the input controls.
If the validationcompareoperator.datatypecheck is selected, then
validation control will ignore both controltocompare and
valuetocompare property, and just checks whether the value
entered in to the input control can be converted into the type
specified by the Type property of the Comparevalidator control.
In this case if input control is empty no value entered, then no
validation functions are called and validation succeeds. Hence
we have to use RequiredFieldValidator for the user not to skip
the input control.
CustomValidator: this control will allow us to create a
validation control with customized validation logic specific to our
application.
Validation controls by default does their validation processing at
server; but we can also make this happen at client side. This
allows the validation to be performed at client before sending the
form to server.
To does validation at server side, we should provide handler for
servervalidate event. The handler takes servervalidateeventargs
which contains value property that client has sent and isvalid
property which server sends the status of validation to client.
If validation is performed at client side then Enableclientscript is
set to true and clientvalidationfunction property is used to
specify the clientside validation script function associated with
the customvalidator.
It is possible to use a customvalidator control with out setting the
controltovalidate property. This is generally used when we want
to validate multiple controls or when we want to validate those
input controls for which validation controls cannot be used such
as checkbox control. In this case the value property in
servervalidateeventargs will be empty. In order to retrieve the
value we have to refer programmatically to the appropriate
control and get its value. For ex: in server validate handler or
client side function for this control we can write as:
Args.isvalid = ( checkbox1.checked =true)
RangeValidatorControl: the control allows us to check whether
the user’s entry is with in specified upper and lower boundary.
We can check ranges with in pairs of numbers, characters, and
dates. Boundaries are expressed as constants.
Controltovalidate property is used for input control and
minimumvalue and maximumvalue properties are used to
specify the range.
The type property is used to specify the datatype of the values to
compare. The types that are supported are: Currency, date,
string, int and double.
If the minimumvalue and maximumvalue property values cannot
be converted to the specified datatype of Type Property then
Rangevalidator will throw an exception.
RegularExpressionValidator: this control will determine the
value specified by the input control matches the pattern defined
by regularexpression control.
Validationexpression property is used to specify the regular
expression used to validate the input control. Both client and
server side validations can be used. But the validation logic
differs in both, if at all it is client side then jscript regular
expression syntax is used. On the server Regex syntax is used.
Jscript is actually a subset of regex.
RequiredFieldValidator: this control is used to make the input
control a mandatory field.
The input control fails its validation if the associated control does
not change from its initial value when validation is performed.
This prevents the user to leave the associated input control
unchanged.
Extra spaces before and end of the input value is removed
before validation is performed.
The initial value property specifies the value to be seen in the
control when displayed initially.
ValidationSummary control: validation summary control
display the error messages of all the controls on the webpage in
a single location. The display could be a list, a bulleted list, or a
paragraph based on the display mode selected.
The summary includes the errormessages of all the validation
controls that failed.
The summary can be controlled from displaying through
showsummary property.
the summary can be given a custom title through HeaderText
property
The summary information can also be given through message
box enabled through showmessagebox property.
Serialization Concepts:
Serialization in basic terms is converting object in to a format
which can be readily passed on to the other process through
communication media.
For an object to be serialized explicitly by the user, its class
should have a serializable attribute.
We can serialize an object with a formatter and deserialize the
object with the same formatter. The deserialization does not
invoke a constructor; it always creates a clone of the object
which it has serialized.
.net supports several types of Serialization like Binary
Serialization, XML Serialization, SOAP serialization, Selective
Serialization, Custom Serialization etc.
For the object to serialize, we need a stream object to store the
serialized format of the object and a formatter to serialize it.
Basically .net supports two formatters they are Binary formatter
and Soap formatter.
The namespace that supports serialization is
system.runtime.serialization. For XML serialization a separate
namespace is present system.xml.serialization.
Binary Serialization is the fastest of all and more memory
efficient as it produces the most compact stream of data after
serialization which occupies limited amount of space.
Binary Serialization serializes all public and private data of the
object; it also serializes the name of the class along with
assembly name. As it serializes the entire information of the
object along with its class and assembly name; the type fidelity
info is preserved. As a result we can deserialize the object any
where else with full type identity.
XML serialization is relatively slower when compared with binary
bcos it has an overhead of creating an XML document in this
process. For an object to get XML serialize its class should have a
default constructor.
The XML serializes only public data of the object; it doesn’t even
serialize the read-only properties of the object. As a result the
type fidelity is not maintained properly in this type of
serialization.
In case of XML serialization as only public data of the object is
serialized; the object type fidelity is not maintained.
SOAP serialization it’s almost same as XML serialization but the
classes which both utilizes comes from two separate
namespaces.
Selective Serialization: In a class we might want certain member
variables not to be serialized, we can prevent this from not being
serialized by keeping nonserializable attribute for this member
fields.
Custom Serialization: as .net supports only two formatters, we
can have our own formatters to do a custom serialization. A class
should implements an IFormatter interface to create a custom
formatter. This custom formatter serializes the object in a
custom specified manner.
In Asp.net sessions have binary serialization. The framework
itself does the binary serialization when session mode is outproc.
In case of viewstate a special type of serialization is seen called
Losformatter. This is a special type of Text serialization where
the string is compact in to a much smaller or compact ASCII text
in order to sustain with lower bandwidth of the page. This
serialization can persist only for a small duration up to page
request time.
Webservices uses soap serialization.
Configuration files in .net like web.config etc are never serialized
they are read by special handlers called configuration section
handlers.
Master Pages
When a web request arrives for an ASP.NET web form using a master
page, the content page (.aspx) and master page (.master) merge their
content together to produce a single page. Let’s say we are using the
following, simple master page.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1"
runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
The master page contains some common elements, like a head tag.
The most important server-side controls are the form tag (form1) and
the ContentPlaceHolder (ContentPlaceHolder1). Let’s also write a
simple web form to use our master page.
The web form contains a single Content control, which in turn is the
proud parent of a Label. We can visualize what the object hierarchies
would look like at design with the following diagram.
At this point, the page and master page are two separate objects, each
with their own children. When it comes to runtime the master page has
to do its job, the master page replaces the page’s children with itself.
The master page’s next step is to look for Content controls in the
controls formerly associated with the page. When the master page
finds a Content control that matches a ContentPlaceHolder, it moves
the controls into the matching ContentPlaceHolder. In our simple
setup, the master page will find a match for ContentPlaceHolder1, and
copy over the Label.
All of this work occurs after the content page’s PreInit event, but
before the content page’s Init event. During this brief slice of time, the
master page is deserving of its name. The master page is in control -
giving orders and rearranging controls. However, by the time the Init
event fires the master page becomes just another child control inside
the page. In fact, the MasterPage class derives from the UserControl
class. Thus master pages are just masters during design time. When
the application is executing, it’s better to think of the master page as
just another child control.
class aaa
{
public static void Main()
{
#if vijay
Console.WriteLine("Defined");
#else
Console.WriteLine("UnDefined");
#endif
}
Output will be “Defined”
using System;
class aaa
{
public static void Main()
{
#if vijay
Console.WriteLine("Defined");
#else
Console.WriteLine("UnDefined");
#endif
}
Output will be now Undefined
But at compilation time if u run this program as
Csc:\d vijay aaa.cs the output will be “Defined” because the \d
has added or defined variable vijay so Defined will be printed.
Thus \d compiler option lets us create identifiers at the time of
compiling the program. This cannot be done with a normal
variable.
Thus the advantage of preprocessor variables is that they can be
added or removed at compilation time which is not possible with
other normal variables.
Structures
OOPs Rule:
SQL Bulk Copy class is used to copy the data from source to
destination.
Source could be a sql database or xml or excel or wht ever it is.
We usually want to transfer or migrate the data between two
tables in the same SQL server or between two different SQL
Servers or also could be between two different types of database
servers.
SQL Bulkcopy class is very useful in this scenario bcos instead of
migrating or transferring row by row it does transfer a bulk of
rows at a time based on the size specified in the property
Batchsize of SQLBulkCopy class.
SQLBulkcopy class has an instance method WriteToServer()
which is able to read from either DataRow[],DataReader and
DataTable. Out of them using datareader is a good idea bcos
data reader is forward only readonly and moreover it does not
store anything in system. So it is fast.
Sometimes we need to transfer the data between tables of
different schema like table 1 having task id taskname taskstatus
and table 2 is have tno tname then we can use bulk copy in this
case by using columnmappings of the bulk copy object.
For ex: sqlbulkcopy obj = new sqlbulkcopy();
Obj.columnmappings.add(“task id”,”tno”);
Obj.columnmappings.add(“taskstatus”,”tname”);
Thus SQL BulkCopy is a new concept in ADO.net 2.0 to bulk
transfer data from source to destination.
GetHashCode():
Providers
All providers are derived from the root base class called
“Provider Base” class. This class contains Name and Description
properties and Initialise method which is called by ASP.net when
the provider is loaded.
Developers typically derive from the providerbase class when
they wanna create a custom provider. Because if they wanna
customize the membership provider to store in different
datastore in a different format instead of deriving from the
providerbase they can derive from membership provider.
Providers are registered in the <Providers> section under the
services they offer for ex:<membership>
For ex:
<membership>
<providers>
<add …../>
</providers>
</membership>
Add element inside the provider register the provider and make
them available to use.
Threading
Debugging Webservices
Agile Processess/Mehtodologies
AJAX
AJAX – Asynchronous javascript and XML
Traditionally web applications mean request/response life cycle.
Any ineteraction with the page will cause the page postback to
server. And at the server a series of events occur and the
response to the browser comes as HTML.
But there is a proficient lag in between this request and response
to be back.
AJAX is a technique to use javascript and XMLHTTPRequest
object to make light weight HTTP requests to the webserver from
client side scripts
Ajax- enabled web pages provides a faster user experience.
The first control which needs to be on the page to have AJAX
functionality is the Script Manager.
EnablePartialRendering attribute of the script manager is set to
true which will allows partial page rendering.
To handle the post back of partial data to the server in AJAX is
handled through update panel control. The update panel consists
of content panel where the server controls are kept
The mode of the update panel is set to conditional which allows
to post only its content to the server when update event on this
panel is called.
The content of update panel will not be sent to server even if the
rest of the page is gong to server.
As the attribute of mode is set to conditional; if it is set to always
then the content of update panel will be sent every time when
the page goes to server
The general misconception which everybody has with AJAX is in
AJAX enabled web pages only a part of web page will go to the
web server on which update is called; but this is not true,
irrespective of actual post back or AJAX post back the whole page
goes to the server.
But there is a difference in how the request goes to the server. In
the normal page post back the whole page hits the server and
the rendered HTML of whole page is given back to the browser
which causes the whole page refresh(as the whole page HTML is
received by the browser).
But in case of AJAX post back the request first hits the ajax script
engine on the client side, this engine consist of client side AJAX
libraries. The central nerve of AJAX is Script Manager control.
This control in the client side library register to the page submit
event.
In this event it recognizes whether it is a page postback or ajax
post back(by keeping the track of update events in all update
panel controls on the page).
If the request is an AJAX post back then it appends a key word
“AJAX” to the request for the easy identification of AJAX postback
on the server.
Thus the whole page hits the server even in the case of AJAX call,
infact some more information is added to the normal page
content to identify it is an ajax call.
Then the only difference it comes is the way the actual page
renders and the ajax page renders. The script manager control
which is present on the page overrides the prerender event. In
this pre render event it calls the method of page request
manager class which will render only that part of the content
which caused postback instead of carrying the whole page
rendered output.
Thus it causes the updation of the control itself with out the
whole page flickering.
Thus the functional difference between page post back and ajax
post back is how the page renders.
WCF vs Webservices:
WPF Overview