Tuesday, November 20, 2012


SQL-What is a View

A View is a "Virtual Table". It is not like a simple table, but is a virtual table which contains columns and data from different tables (may be one or more tables). A View does not contain any data, it is a set of queries that are applied to one or more tables that is stored within the database as an object. After creating a view from some table(s), it used as a reference of those tables and when executed, it shows only those data which are already mentioned in the query during the creation of the View.
View1.JPG

Views are used as security mechanisms in databases. Because it restricts the user from viewing certain column and rows. Views display only those data which are mentioned in the query, so it shows only data which is returned by the query that is defined at the time of creation of the View. The rest of the data is totally abstract from the end user.
Along with security, another advantage of Views is data abstraction because the end user is not aware of all the data in a table.

Uses

We begin with creating 3 tables PRODUCTSCustomer BOOKING. These are fictitious tables for our demo. ThePRODUCTS stores data for a retail shop with a flag column IsSalable based on whose value we treat the products as Salable.
CREATE TABLE PRODUCTS
(ProductID INT PRIMARY KEY CLUSTERED,
ProductDesc VARCHAR(50) NOT NULL,
ManufacturingDate DATETIME,
ExpiryDate DATETIME,
IsSalable BIT,--1 Salable/Active FOR 0 For NonSalable/Passive Product
Price MONEY NOT NULL
)
Next, we have a Customer table which stores UserID and Password details for customers.
CREATE TABLE Customer
(CustID INT IDENTITY(1002,2)PRIMARY KEY CLUSTERED,
 FName VARCHAR(50) NOT NULL,
 LNme VARCHAR(50) NOT NULL,
 UserID VARCHAR(100) NOT NULL,
 Pswd NVARCHAR(100) NOT NULL DEFAULT 'password123'
)
Lastly, I have created a BOOKING table which houses all the bookings from different customers.
CREATE TABLE BOOKING
( BookingID INT IDENTITY(10,2) PRIMARY KEY CLUSTERED,
  ProductID INT REFERENCES dbo.Products(ProductID),
  CustID INT REFERENCES dbo.Customer(CustID),
  DateOfBooking DATETIME NOT NULL,
  QTY INT
)
Next, insert a few records into these tables:
INSERT INTO PRODUCTS VALUES
(1,'Biscuits','2011-09-01 00:00:00.000','2012-09-01 00:00:00.000',1,20),
(2,'Butter','2010-09-01 00:00:00.000','2011-09-01 00:00:00.000',1,30),
(3,'Milk','2011-10-01 00:00:00.000','2011-11-01 00:00:00.000',1,46)

INSERT INTO Customer (FName,LNme,UserID,Pswd)
 VALUES
('Sara','Verma','S.Verma@abc.com','S123'),
('Rick','Singh','G.Singh@xyz.com','G311'),
('Micky','Khera','M.Khera@mno.com','M222')

INSERT INTO BOOKING (ProductID,CustID,DateOfBooking,QTY)
VALUES
(1,1002,'2011-11-01 00:00:00.000',3),
(2,1004,GETDATE(),4),
(3,1006,'2011-10-01 00:00:00.000',2)
Our tables contents look like this. I know the tables are not completely normalized, for now please ignore them, these are simple demo tables.
SELECT * FROM Customer
CustID      FName     LNme    UserID           Pswd
--------- -------- ---------- ---------------  ---------
1002        Sara   Verma      S.Verma@abc.com  S123
1004        Rick   Singh      G.Singh@xyz.com  G311
1006        Micky  Khera       M.Khera@mno.com M222

(3 row(s) affected)

Select * from PRODUCTS

ProductID  ProductDesc  ManufacturingDate       ExpiryDate              IsSalable Price
---------- ------------ ----------------------- ----------------------- --------- -------
1          Biscuits     2011-09-01 00:00:00.000 2012-09-01 00:00:00.000 1         20.00
2          Butter       2010-09-01 00:00:00.000 2011-09-01 00:00:00.000 1         30.00
3          Milk         2011-10-01 00:00:00.000 2011-11-01 00:00:00.000 1         46.00

(3 row(s) affected)

Select * from BOOKING
BookingID   ProductID   CustID      DateOfBooking           QTY
----------- ----------- ----------- ----------------------- -----------
10          1           1002        2011-11-01 00:00:00.000 3
12          2           1004        2011-10-09 17:31:31.790 4
14          3           1006        2011-10-01 00:00:00.000 2

(3 row(s) affected)
customer purchases/books a product and the same gets recorded into the BOOKING table now to generate the bill on his name we can uses a VIEW which would help us do away with a physical table. Instead it would enable us to generate the bill based on the information from these 3 tables itself. Let’s see how it’s possible.
CREATE VIEW Bill_V
AS
SELECT C.FName
      ,C.LNme
      ,P.ProductDesc
      ,B.DateOfBooking
      ,P.Price
      ,B.QTY
      ,(B.QTY*P.Price) AS TotalAmountPayable
FROM BOOKING B
INNER JOIN PRODUCTS P
ON B.ProductID=P.ProductID
INNER JOIN Customer C
ON B.CustID=C.CustID;
Next if I,
Select * from Bill_V
FName     LNme   ProductDesc DateOfBooking         Price   QTY     TotalAmountPayable
-------------------------------------------------- ------------------------------------
Sara      Verma  Biscuits   2011-11-01 00:00:00.000 20.00  3       60.00
Rick      Singh  Butter     2011-10-09 17:31:31.790 30.00  4       120.00
Micky     Khera  Milk       2011-10-01 00:00:00.000 46.00  2       92.00

(3 row(s) affected)
We have been able to generate the bill based on the 3 tables hence we have not only optimized the bill generation also we have saved ourselves from hosting a physical table in the database with this information.
  • This is the most credible use of a VIEW; it can not only reduce apparent complexity but also prevent redundant hosting of data in the DB.Next say there is some API which enables the Customer care executives to view the customerinformation details. Now exposing the Password might be risky, it’s strictly confidential info.
    We create a View which can be exposed to the API:
    CREATE VIEW dbo.CustomerInfo_V
    AS
    Select CustID
          ,FNAME AS [FIRST NAME]
          ,LNME AS [LAST NAME]
          ,UserID
    FROM dbo.Customer
    We have a created a View which can be used by the API to fetch customer details –(Minus) the Password Column.
  • Views can be used to prevent sensitive information from being selected, while still allowing other important data.Views do not have a physical existence, but still they do return a set of record set as a table does, the differences is it is simply an additional layer which calls the underlying code which finally returns the record set.



Sunday, November 18, 2012

How to start in Stock Markets?



Would you like to become a business owner without ever having to show up at work? I am sure all of you would. I am not talking about you getting a windfall gain through dowry; I am talking about you holding shares of a listed company on stock markets.
You must be wondering what this stock marketis? No, it is not a place where you sell goods, it is a place where securities (like shares and bonds) are bought and sold. ‘Share’ means a share in share capital of the company. In simple terms, if you buy some shares of a company you get part ownership of that company. Sounds good? Yes, it is very simple – but there is always risk involved in it. Why do I say it is risky? The value of a share can go down for several known and unknown reasons.
So how does one go about buying shares? How can I become a successful investor like Warren Buffet? FYI – Warren Buffet is widely regarded as one of the most successful investor in the world. Before you buy shares, you should know where and how you can buy them.
Step 1:  First open a Trading and Demat account with a registered broker. I don’t understand what this Trading Account or Demat Account mean, can you elaborate? ‘Trading Account’ – Just like you need a bank account to debit and creditcash, you need a trading account to buy and sell shares ‘Demat Account’ refers to dematerialized account which holds all your share certificates in electronic form rather than paper. How would you do that?
Simple, go to Google and search for registered brokerage houses in India you will find so many companies like HDFC, ICICI, SBI etc. Go to any brokerage house website you want to open your account with and call the toll free numberavailable on the website – within few minutes a representative from that company will fly into your house to give all necessary details of opening a new account.
Step 2: After collecting information of two or three brokerage firms you might decide to open an account with one who charges less brokerage charge and gives you good customer caresupport. What is a brokerage charge? When you buy or sell shares you will have to pay .5% or even less charge for that transaction. What other expenses do I incur when I buy/sell shares? You pay service tax and some other taxes for that transaction. How will I know about these charges? You will receive a report onto your email the same day or the next day of yourtrade.
Step 3: After having decided to open a Tradingand Demat account. You should mentally prepare yourself to sign several pages of application formAh! Once you are done you need to wait for few more days to get your account activated. Yuppie! You’re done with registration and activation. What next? You need to put some money intoyour account. How much?
Start Small – Don’t put all your money initially. First, learn about yourself and the market. What kind of player are you? Are you an Investor or a Trader or a Gambler? Gamblers are those who treat market as casino and play with it - never become a gambler unless you are a rich guy and you just want spend..spend..and only spend.Trader is an opportunist, who takes advantage of mispricing and makes profit from excessive greed and fear. An Investor is one who is optimistic, who has a long term view, who is ‘buy and hold’ types – who does lot of fundamental analysis of the company and buys shares which he thinks would do well in future.
Don’t get excited and jump without thinking – start learning about stock markets. What is NIFTY? What is SENSEX? How to analyze a company? How to select a good company in the current scenario? Read articles, books on fundamental analysis like ‘Warren Buffet way’ by Robert Hagstorm.
Now I know the basics of stock markets, what next? Observe the market. How it is behaving? Why is it going up/down? What do so called experts on the news channel say? You may wonder “how long should I observe the market?” The answer is “till you become completely familiar and confident about your decision to buy some company stocks/shares”. Try to get details about Price-Equity Ratio (P/E Ratio), Market Cap, Volumes etc of the company you are interested in -understand the business model. Shortlist one good stock which you think would do well in future and can give you above average returns – Invest in small quantities.
Don’t relax - keep tracking the company you have invested in; have a target price in mind; sell shares when you reach the target. Always good to be prepared for uncertainty, isn’t it? Have max fall of the share from your buying price you can afford to lose in mind; if the price of the share falls below that value; sell them by booking loss.
Practice and have a strategy that gives you good returns and learn from your mistakes.
Remember, stock markets are not a place to become rich overnight. Only few people are successful in this profession.

Top 10 Facebook facts ahead of its IPO


Top 10 Facebook facts ahead of its IPO


fb-sue.jpg

1) Facebook has more than 900 million active users. If the company were a country, it would be the third largest in the world after China (population: 1.34 billion) and India (population: 1.17 billion).

2) With 157 million members, the United States has the most Facebook users, followed by India with 45.9 million, Brazil with 45.3 million, Indonesia with 42.4 million and Mexico with 32.9 million. (source: socialbakers.com)

3) Facebook is the most popular social network in every country of the world, with the exceptions of China, Japan, Russia, South Korea and Vietnam. (source: comScore)

4) In April, Facebook announced a billion-dollar deal to buy the startup behind wildly popular smartphone photo sharing application Instagram, its biggest acquisition to date.

5) Facebook has minted four billionaires: Mark Zuckerberg, Dustin Moskovitz, Eduardo Saverin and Sean Parker. The 27-year-old Zuckerberg's net worth was estimated at $17.5 billion on the 2011 Forbes list of the wealthiest Americans. Moskovitz had a net worth of $3.5 billion but pipped Zuckerberg for the title of world's youngest billionaire, being eight days younger. The Brazilian-born Saverin, who left Facebook early on after a falling-out with Zuckerberg, had a net worth of $2 billion. Parker, the Napster co-founder who briefly served as Facebook's president, had a net worth of $2.1 billion.

6) Chris Hughes, one of Facebook's four co-founders, served as director of online organizing for Barack Obama's successful 2008 presidential campaign.

7) Facebook says it had an average of 526 million daily active users in March 2012, an increase of 41 percent from a year ago. It had registered 125 billion "friend connections" as of March 31 and 3.2 billion "likes" and comments.

8) More than 300 million photos are uploaded to Facebook every day and more than 488 million active users access Facebook using mobile devices.

9) "The Social Network," the 2010 film about the origins of Facebook, won four Golden Globes -- including for best picture and best director -- but flopped at the Oscars, walking away with only awards for best adapted screenplay, original score and film editing.

10) Facebook, which currently employs some 3,500 people, has announced plans to hire "thousands" more over the next year.

Friday, July 20, 2012

Scribd:Online Library

scribd is a big online library where everyone can publish original content.
... the idea behind Scribd is that everyone has a lot of documents sitting around on their computers that only they can read. With Scribd we hope to unlock this information by putting it on the web.

Make your own site in wix.com

on wix.com we can make our own sites

my site

www.wix.com/bhanu05/wwwvinsharecom

Tuesday, July 17, 2012

Ten hot new features of Microsoft next generation Office suite

Software giant Microsoft has unveiled the next generation of its Office softwares - including Word, Excel, Outlook, Access, PowerPoint and One-Note applications.

The refreshed Office suite - which includes Microsoft Office 2013, adesktop version as well as Office 365 (a subscription-based version for both enterprises and individuals) - blends touch, social and cloud capabilities , creating a much-needed simplified and intuitive user experience that had several users remark, "Finally!".

Office documents can now also be stored on to SkyDrive, Microsoft's cloud storage service for documents. And Office will be offered as a service rather than just the PC download version it has traditionally been associated with. However , prices and exact launch dates are yet to be announced.

Google has been winning one-thirds to half of new corporate users that are paying for its web-based software. And, as The Wall Street Journal reported, Microsoft actually has a "Google Compete" team just to keep Office customers from switching over to Google products. Analysts feel these new features of Office could help Microsoft gain an edge over its rival.

Here are the ten hot new features that new Office suite offers

1) A neat look with touch features

2) Cloud: Seamless access to documents, apps and personalised settings across devices

3) One-click multi-party video conferencing in HD along with file sharing

4) Import PDF content, work with online images and watch videos within Word

5) Quick in-line reply feature in Outlook; Bing Maps navigates to an address within the email



6) Improved collaboration features such as co-authoring of PowerPoint presentations

7) Inking: One can highlight and write notes, mimicking hand writing

8) Calendar lets you glance quickly at your schedule without rearranging windows

9) View contacts and activity feeds to multiple social networks in Outlook

10) Office as a service: Following the SaaS model with automatic updates to new features

BE HAPPY :)


INFO ABOUT ASP.NET PAGE LIFE CYCLE


In this article, we will try to understand what the different events are which take place right from the time the user sends a request, until the time the request is rendered on the browser. So we will first try to understand the two broader steps of an ASP.NET request and then we will move into different events emitted from ‘HttpHandler’, ‘HttpModule’ and ASP.NET page object. As we move in this event journey, we will try to understand what kind of logic should go in each and every one of these events.
This is a small Ebook for all my .NET friends which covers topics like WCF, WPF, WWF, Ajax, Core .NET, SQL, etc. 
From 30,000 feet level, ASP.NET request processing is a 2 step process as shown below. User sends a request to the IIS:
  • ASP.NET creates an environment which can process the request. In other words, it creates the application object, request, response and context objects to process the request.
  • Once the environment is created, the request is processed through a series of events which is processed by using modules, handlers and page objects. To keep it short, let's name this step as MHPM (Module, handler, page and Module event), we will come to details later.
In the coming sections, we will understand both these main steps in more detail.

Creation of ASP.NET Environment

Step 1: The user sends a request to IIS. IIS first checks which ISAPI extension can serve this request. Depending on file extension the request is processed. For instance, if the page is an ‘.ASPX page’, then it will be passed to ‘aspnet_isapi.dll’ for processing.

Step 2: If this is the first request to the website, then a class called as ‘ApplicationManager’ creates an application domain where the website can run. As we all know, the application domain creates isolation between two web applications hosted on the same IIS. So in case there is an issue in one app domain, it does not affect the other app domain.

Step 3: The newly created application domain creates hosting environment, i.e. the ‘HttpRuntime’ object. Once the hosting environment is created, the necessary core ASP.NET objects like ‘HttpContext’ , ‘HttpRequest’ and ‘HttpResponse’ objects are created.

Step 4: Once all the core ASP.NET objects are created, ‘HttpApplication’ object is created to serve the request. In case you have a ‘global.asax’ file in your system, then the object of the ‘global.asax’ file will be created. Please note global.asax file inherits from ‘HttpApplication’ class.
Note: The first time an ASP.NET page is attached to an application, a new instance of ‘HttpApplication’ is created. Said and done to maximize performance, HttpApplication instances might be reused for multiple requests.

Step 5: The HttpApplication object is then assigned to the core ASP.NET objects to process the page.

Step 6: HttpApplication then starts processing the request by HTTP module events, handlers and page events. It fires the MHPM event for request processing.
Note: For more details, read this.
The below image explains how the internal object model looks like for an ASP.NET request. At the top level is the ASP.NET runtime which creates an ‘Appdomain’ which in turn has ‘HttpRuntime’ with ‘request’, ‘response’ and ‘context’ objects.

Process Request using MHPM Events Fired

Once ‘HttpApplication’ is created, it starts processing requests. It goes through 3 different sections ‘HttpModule’ , ‘Page’ and ‘HttpHandler’. As it moves through these sections, it invokes different events which the developer can extend and add customize logic to the same.
Before we move ahead, let's understand what are ‘HttpModule’ and ‘HttpHandlers’. They help us to inject custom logic before and after the ASP.NET page is processed. The main differences between both of them are:
  • If you want to inject logic based in file extensions like ‘.ASPX’, ‘.HTML’, then you use ‘HttpHandler’. In other words, ‘HttpHandler’ is an extension based processor.
  • If you want to inject logic in the events of ASP.NET pipleline, then you use ‘HttpModule’. ASP.NET. In other words, ‘HttpModule’ is an event based processor.
You can read more about the differences from here.
Below is the logical flow of how the request is processed. There are 4 important steps MHPM as explained below:

Step 1(M: HttpModule): Client request processing starts. Before the ASP.NET engine goes and creates the ASP.NET HttpModule emits events which can be used to inject customized logic. There are 6 important events which you can utilize before your page object is created BeginRequestAuthenticateRequest,AuthorizeRequestResolveRequestCacheAcquireRequestState andPreRequestHandlerExecute.

Step 2 (H: ‘HttpHandler’): Once the above 6 events are fired, ASP.NET engine will invoke ProcessRequestevent if you have implemented HttpHandler in your project.

Step 3 (P: ASP.NET page): Once the HttpHandler logic executes, the ASP.NET page object is created. While the ASP.NET page object is created, many events are fired which can help us to write our custom logic inside those page events. There are 6 important events which provides us placeholder to write logic inside ASP.NET pages InitLoadvalidateeventrender and unload. You can remember the word SILVERto remember the events S – Start (does not signify anything as such just forms the word) , I – (Init) , L (Load) , V (Validate), E (Event) and R (Render).

Step4 (M: HttpModule): Once the page object is executed and unloaded from memory, HttpModule provides post page execution events which can be used to inject custom post-processing logic. There are 4 important post-processing events PostRequestHandlerExecuteReleaserequestStateUpdateRequestCacheand EndRequest.
The below figure shows the same in a pictorial format.

In What Event Should We Do What?

The million dollar question is in which events should we do what? Below is the table which shows in which event what kind of logic or code can go.
SectionEventDescription
HttpModuleBeginRequestThis event signals a new request; it is guaranteed to be raised on each request.
HttpModuleAuthenticateRequestThis event signals that ASP.NET runtime is ready to authenticate the user. Any authentication code can be injected here.
HttpModuleAuthorizeRequestThis event signals that ASP.NET runtime is ready to authorize the user. Any authorization code can be injected here.
HttpModuleResolveRequestCacheIn ASP.NET, we normally use outputcache directive to do caching. In this event, ASP.NET runtime determines if the page can be served from the cache rather than loading the patch from scratch. Any caching specific activity can be injected here.
HttpModuleAcquireRequestStateThis event signals that ASP.NET runtime is ready to acquire session variables. Any processing you would like to do on session variables.
HttpModulePreRequestHandlerExecuteThis event is raised just prior to handling control to the HttpHandler. Before you want the control to be handed over to the handler any pre-processing you would like to do.
HttpHandlerProcessRequestHttphandler logic is executed. In this section, we will write logic which needs to be executed as per page extensions.
PageInitThis event happens in the ASP.NET page and can be used for:
  • Creating controls dynamically, in case you have controls to be created on runtime.
  • Any setting initialization.
  • Master pages and the settings.
In this section, we do not have access to viewstate, postedvalues and neither the controls are initialized.
PageLoadIn this section, the ASP.NET controls are fully loaded and you write UI manipulation logic or any other logic over here.
PageValidateIf you have valuators on your page, you would like to check the same here.
RenderIt’s now time to send the output to the browser. If you would like to make some changes to the final HTML which is going out to the browser, you can enter your HTML logic here.
PageUnloadPage object is unloaded from the memory.
HttpModulePostRequestHandlerExecuteAny logic you would like to inject after the handlers are executed.
HttpModuleReleaserequestStateIf you would like to save update some state variables like session variables.
HttpModuleUpdateRequestCacheBefore you end, if you want to update your cache.
HttpModuleEndRequestThis is the last stage before your output is sent to the client browser.

A Sample Code for Demonstration

With this article, we have attached a sample code which shows how the events actually fire. In this code, we have created a ‘HttpModule’ and ‘Httphandler’ in this project and we have displayed a simple response write in all events, below is how the output looks like.
Below is the class for ‘HttpModule’ which tracks all events and adds it to a global collection.
public class clsHttpModule : IHttpModule
{
...... 
void OnUpdateRequestCache(object sender, EventArgs a)
{
objArrayList.Add("httpModule:OnUpdateRequestCache");
}
void OnReleaseRequestState(object sender, EventArgs a)
{
objArrayList.Add("httpModule:OnReleaseRequestState");
}
void OnPostRequestHandlerExecute(object sender, EventArgs a)
{
objArrayList.Add("httpModule:OnPostRequestHandlerExecute");
}
void OnPreRequestHandlerExecute(object sender, EventArgs a)
{
objArrayList.Add("httpModule:OnPreRequestHandlerExecute");
}
void OnAcquireRequestState(object sender, EventArgs a)
{
objArrayList.Add("httpModule:OnAcquireRequestState");
}
void OnResolveRequestCache(object sender, EventArgs a)
{
objArrayList.Add("httpModule:OnResolveRequestCache");
}
void OnAuthorization(object sender, EventArgs a)
{
objArrayList.Add("httpModule:OnAuthorization");
}
void OnAuthentication(object sender, EventArgs a)
{

objArrayList.Add("httpModule:AuthenticateRequest");
}
void OnBeginrequest(object sender, EventArgs a)
{

objArrayList.Add("httpModule:BeginRequest");
}
void OnEndRequest(object sender, EventArgs a)
{
objArrayList.Add("httpModule:EndRequest");
objArrayList.Add("<hr>");
foreach (string str in objArrayList)
{
httpApp.Context.Response.Write(str + "<br>") ;
}
} 
}
Below is the code snippet for ‘HttpHandler’ which tracks ‘ProcessRequest’ event.
public class clsHttpHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
clsHttpModule.objArrayList.Add("HttpHandler:ProcessRequest");
context.Response.Redirect("Default.aspx");
}
}
We are also tracking all the events from the ASP.NET page.
public partial class _Default : System.Web.UI.Page 
{
protected void Page_init(object sender, EventArgs e)
{

clsHttpModule.objArrayList.Add("Page:Init");
}
protected void Page_Load(object sender, EventArgs e)
{
clsHttpModule.objArrayList.Add("Page:Load");
}
public override void Validate() 
{
clsHttpModule.objArrayList.Add("Page:Validate");
}
protected void Button1_Click(object sender, EventArgs e)
{
clsHttpModule.objArrayList.Add("Page:Event");
}
protected override void Render(HtmlTextWriter output) 
{
clsHttpModule.objArrayList.Add("Page:Render");
base.Render(output);
}
protected void Page_Unload(object sender, EventArgs e)
{
clsHttpModule.objArrayList.Add("Page:UnLoad");
}}
Below is how the display looks like with all events as per the sequence discussed in the previous section.

Zooming ASP.NET Page Events

In the above section, we have seen the overall flow of events for an ASP.NET page request. One of the most important sections is the ASP.NET page, we have not discussed the same in detail. So let’s take some luxury to describe the ASP.NET page events in more detail in this section.
Any ASP.NET page has 2 parts, one is the page which is displayed on the browser which has HTML tags, hidden values in form of viewstate and data on the HTML inputs. When the page is posted, these HTML tags are created in to ASP.NET controls with viewstate and form data tied up together on the server. Once you get these full server controls on the behind code, you can execute and write your own login on the same and render the page back to the browser.
Now between these HTML controls coming live on the server as ASP.NET controls, the ASP.NET page emits out lot of events which can be consumed to inject logic. Depending on what task / logic you want to perform, we need to put this logic appropriately in those events.
Note: Most of the developers directly use the page_load method for everything, which is not a good thought. So it’s either populating the controls, setting view state, applying themes, etc., everything happens on the page load. So if we can put logic in proper events as per the nature of the logic, that would really make your code clean.
SeqEventsControls InitializedView state
Available
Form data
Available
What Logic can be written here?
1InitNoNoNo
Note: You can access form data etc. by using ASP.NET request objects but not by Server controls.Creating controls dynamically, in case you have controls to be created on runtime. Any settinginitialization.Master pages and them settings. In this section, we do not have access to viewstate , posted values and neither the controls are initialized.
2Load view stateNot guaranteedYesNot guaranteedYou can access view state and any synch logic where you want viewstate to be pushed to behind code variables can be done here.
3PostBackdataNot guaranteedYesYesYou can access form data. Any logic where you want the form data to be pushed to behind code variables can be done here.
4LoadYesYesYesThis is the place where you will put any logic you want to operate on the controls. Like flourishing a combobox from the database, sorting data on a grid, etc. In this event, we get access to all controls, viewstate and their posted values.
5ValidateYesYesYesIf your page has validators or you want to execute validation for your page, this is the right place to the same.
6EventYesYesYesIf this is a post back by a button click or a dropdown change, then the relative events will be fired. Any kind of logic which is related to that event can be executed here.
7Pre-renderYesYesYesIf you want to make final changes to the UI objects like changing tree structure or property values, before these controls are saved in to view state.
8Save view stateYesYesYesOnce all changes to server controls are done, this event can be an opportunity to save control data in to view state.
9RenderYesYesYesIf you want to add some custom HTML to the output this is the place you can.
10UnloadYesYesYesAny kind of clean up you would like to do here.