Sunday 31 May 2020

Asp.Net Material & Examples

Page Life Cycle of Asp.Net



Page Request
The page request occurs before the page life cycle begins, i.e. when the page is requested by a user. It determines whether the page needs to be parsed and compiled (therefore beginning the life of a page) or whether a cached version of the page can be sent in response without running the page.


Stage1: Start
In this stage the page properties such as request and response are created and set, and at this stage the page also determines whether the request is a postback or a new request and sets the IsPostBack property, which will be true if it’s a PostBack or else false if it’s a first request.

Stage2: Initialization
During this stage all the controls on the page will be created and each controls unique Id property will be set.
Stage3: Load
In this stage if the current request is a postback, control properties are loaded with information retrieved from view state.

Stage4: Validation 
In this stage any server side validations that are required will be performed and sets the IsValid property of individual validator controls and then of the page.

Stage5: Postback Event Handling
If the request is a posback then all the controls corresponding event procedures are called (which is required only) along with any cached events also.

Stage6: Rendering
In this stage the page is rendered i.e. converts into html format and before rendering view state and control state is saved for the page and all controls.
Note:During the rendering stage, page calls the render method for each control and writes its output to the OutputStream object of the page’s Response property.

Stage7: UnLoad:
After the page has been rendered and the output is sent to the client,it’s ready to discard and Unload event is raised,and at this stage the Request and Response properties are destroyed and cleanup is performed.
Page Events:
Within each stage of the page life cycle, the page raises certain events which can be used for performing different actions. List of page Life Cycle events that we will use most frequently:

1.  PreInit
2.  Init
3.  InitComplete
4.  PreLoad
5.  Load
-Control Events (All Postbackand Cached Events)
6.  LoadComplete
7.  PreRender
8.  PreRenderComplete
9.  SaveStateComplete
 -RenderMethod Calling
10.    UnLoad

1.PreInit: Raised after the start stage is complete and before the initialization stage begins. We use this event forperforming the following action:
  •   Check the IsPostBack property to determine whether this is the first time page is being         processed.   
  • The IsCallback and IsCrossPagePostBack properties are also set at this time.
  •   Create or re-create dynamic controls.
  •  Set a master page dynamically.
  • Set the Theme property dynamically.


2.Init:  Raised after all controls have been initialized and any skin settings have been applied. The Init event of individual controls occurs before the Init event of the page. Use this event to read or initialize control properties.

3. InitComplete: Raised at the end of page's initialization stage. Only one operation takes place between the Init and InitComplete events i.e. tracking of view state is turned on. View state tracking enables controls to persist any values that are programmatically added to the ViewState collection. Until view state tracking is turned on, any values added to view state are lost across postbacks. Controls typically turn on view state tracking immediately after they raise their Init event. Use this event to make changes to view state that you want to make sure are persisted after the next postback.

4. PreLoad: Raised after the page loads view state for itself and all controls, and after it starts processingpostback data that is included with the Request object.

5. Load: The Page object calls the OnLoad method on the Page object, and then recursively does the same for each child control until all controls are loaded. The Load event of individual controls occurs after the Load event of page. Use this event to get or set properties to controls and to establish database connections.

Control events: Use these events to handle specific control events, such as a Button control's Click event or a TextBox control's TextChanged event.In a postback request, if the page contains validation controls, check the IsValid property of the Page before performing any processing.

6. LoadComplete: Raised at the end of event-handling stage. Use this event for tasks that require for all other controls on the page been loaded.

7. PreRender: Raised after the Page object has created all controls that are required in order to render the page, including child controls of composite controls.The Page object raises the PreRender event on itself and then recursively does the same for each child control. Use this event to make final changes to contents of the page or its controlsbefore the rendering stage begins.

8. PreRenderComplete: Raised after the controls on the page are ready for render.

9. SaveStateComplete: Raised after view state and control state have been saved for the page and for all controls. Any changes to the page or controls at this point affect rendering, will not be retrieved on the next postback.

Render: This is not an event; at this stage of processing, the Page object calls this method on each control.

Note:All ASP.NET Web server controls have a RenderControl method that writes out the control's markup that has to be sent to the browser as output.

10. Unload: Raised for each control and then for the page. Use this event to do final cleanup for specific controls, such as closing control-specific database connections.

Note:During the unload stage, the page and its controls rendering is completed, so you cannot make further changes to the response stream. If you attempt to call a method such as the Response.Write, page will throw an exception.

AutoEventWireUp:Pages also support automatic event wire-up, meaning that ASP.Net looks for methods with particular names and automatically runs those methods when certain events are raised. If the AutoEventWireup attribute of the @Page directive is set to true, page events are automatically bound to methods that use the naming convention of Page_Event such as Page_Load,Page_PreInit, Page_Unloadetc.



Posted By:  pankaj_bhakre

"हम घर पर ही रुख जाएंगे" !!


देश के लिए कुछ कर जाएंगे
इसके लिए हम घर पर ही रुख जाएंगे
कौन कहता है की सिर्फ बलिदानो से जंग जीती जा सकती है
खुद को बचाकर हम ये जंग जीत जाएंगे
और इसके लिए हम घर पर ही रुख जाएंगे

गजब का है ये virus साहब
पहले क्या कम दुरिया थी
जो इसने और दूरिया बढ़ा दी
आपसी रिश्तों को फिर से जगाएंगे
और इसके लिए हम घर पर ही रुख जाएंगे

मंदिर मश्शिद के भेदभाव में आजतक लढ रहे
आज के कठीण  समय में कोई साथ नहीं आए ,
सिमा की जवानों की तरह doctors  लढ रहे

हम सभी अपना अपना धर्म भूलकर  उनका हौसला बढ़ाएंगे
और इसके लिए हम घर पर ही रुख जाएंगे


#Corona#stayhomestaysafe

Posted By : pankaj_bhakre

Saturday 30 May 2020

तुझं मन


काय तुझ्या मनात चालतं माहिती नाही मला ,
पण त्या सगळ्या गोष्ठी माहिती करून घ्यायाची इच्छा असते मला
तुझे हसुन बोलने अणि मध्येच शांत होने confuse करतं मला
यामुळे वेगवेगळ्या विचारांचे direction  येतात माझ्या मनाला

नको करू विचार जुन्या गोष्टींचा,
स्वतावर विश्वास ठेऊन सामना कर जगाचा
आयुष्यातून एक व्यक्ति गेला म्हणजे आयुष्य थांबत नसतं
ज्यानां दूर जायच  असतं त्यांना  थांबवायच नसतं

डोळ्यातील अश्रु अणि हृदयातील मन त्यांना  च ध्यावे ज्यानां त्यांची जाणीव असते
जे आपले नसतात त्यांना त्याची जाणीव नसते

कोणाच्या मिठीत असणे अणि मनात असणे यात फरक असतो
मिठीतली व्यक्ति आपल्याला दूर करू शकते
पण मनातली व्यक्ति आपल्याला कधीच दूर करत नसते

Posted By : pankaj_bhakre

Nature is pleased with simplicity

Trip to Pitalkhora

1 / 8
Beautiful Nature
2 / 8
Friends
3 / 8
Rocky Hills
4 / 8
PitalKhora Jungle
5 / 8
Waterfall
6 / 8
Caves
7 / 8
Waterfall
8 / 8
Taking Rest

The Pitalkhora Caves are situated around 50 km from the famous Ellora caves
in Aurangabad.These are rock-cut caves located in the Satamala Hill
Ranges of Maharashtra.Pitalkhora Caves are situated near the town of Kannad
on the Aurangabad-Chalisgaon Road.Pitalkhora is a group of 14 Buddhist
caves which are carved out of basalt rocks. Among 14 rock-cut caves,four 
are chaityas (prayer halls), one has a stupa and the rest are viharas.

October to February is the best time to visit Pitalkhora Caves.  
This is because the hill out of which the caves are carved look 
splendid after the monsoons. It is a visual treat to see the hills 
covered by the lush green cover.


                  #चारोळी#life
जिंदगी की जंग लढते लढते युही सोचा कभी कभी
सब कुछ अपना लिया हमने,गलत हो या सही.
मैने दिल से कहा ढूंढ़ लाना खुशी कभी
नासमझ ये दिल गम लाया , तो ये गम ही सही

Posted By: pankaj_bhakre

Thursday 28 May 2020

                               #चारोळी#प्रेम


जस पक्षी प्रेम दाखवण्यासाठी नेहमीच दाणे आणि पानी  देणे  जरुरी नसत ,
तर खिडकीतून आत  आलेल्या  पक्ष्याला वाचवण्यासाठी पटकन पंखा  बंद करने सुद्धा प्रेम असत.
तसच प्रेमामद्ये  प्रेमाच्या चार गोष्टीच नेहमी जरुरी नसत
तर चोरुन चोरुन Dp आणि Active  Now  बघन सुद्धा प्रेम असत


 Posted By : pankaj_bhakre

Wednesday 27 May 2020

MVC Examples


CRUD operations using ASP.Net MVC with SQL server

Detail step by step procedure is given below

Step1:In SQL server,create database EmployeeDB. In this database create one table tbl_Employee  with following columns.


Step2:
Create Asp.Net MVC Project named as MVCCrud and select ‘Empty’ ‘MVC’ template as shown in fig below

Step3: Right click on Models folder & add AdoNet Data Model in which select ‘Code first from database’ as shown below


After adding data model our Models folder will look like this.

Note: Before adding controller build your solution once

Step4: Right click on Controller folder & add the following controller option
After selecting the above option a new window will open & add Model class & data context class name


This will add all insert update delete operations to our controller. Now run our application and see the result as below.
This is showing complete list of employee in table.


If you click on Create New  button then it will redirect to following page. Insert all details and then click Create button  employee list will update as shown below


The updated employee list is displaying below


Similarly edit update & delete operations also performed by clicking on edit & delete button 

Hope you like this article  

Posted By: pankaj_bhakre

Fibonacci Series in C#


using System;
  public class FibonacciExample
   {
     public static void Main(string[] args)
      {
         int n1=0,n2=1,n3,i,number; 
         Console.Write("Enter the number of elements: "); 
         number = int.Parse(Console.ReadLine());
         Console.Write(n1+" "+n2+" "); //printing 0 and 1 
         for(i=2;i<number;++i) //loop starts from 2 because 0 and 1 are already printed 
         { 
          n3=n1+n2; 
          Console.Write(n3+" "); 
          n1=n2; 
          n2=n3; 
         } 
      }
   }


Posted By: pankaj_bhakre  
Collect Moment, Not Things.

Trip to Matheran

1 / 6
Matheran Entry
2 / 6
In the Midst of Jungle
3 / 6
@Louisa point
4 / 6
Panorama Chalo(sarcastically)
5 / 6
Toy Train Route
6 / 6
Horse Riding



Matheran is a cosy little hill station that stands at an elevation of 2600 
feet above sea level,and is just 100 kilometres away from Mumbai,making
it the perfect weekend getaway.With its name literally translating
to “overhead forest”,
Matheran is the smallest hill station in all of India, but it is extremely
popular in terms of tourists looking for a short trip.
Matheran is famous for its viewpoints.Most of these points have easy trekking trails,
and they offer sweeping views of the mountains, the sunrise, sunset,and everything 
in between! Charlotte Lake, close to Echo Point, is a very popular picnic spot
   

Tuesday 26 May 2020

#चारोळी#life
जिंदगी को बेहतर बनाने के लीये
जिंदगी को ही वक्त नही दे पा रहे हम
खुद को साबीत करणे के लीये 
अपनो से झूूूठ बोल रहे हम

Posted By:pankaj_bhakre

Monday 25 May 2020

Reverse a string

Program to reverse a string in C#.
using System; 
 
namespace reverseString 

    class Program 
    { 
        static void Main(string[] args) 
        { 
            string str = "", reverse = ""; 
            int Length = 0; 
            Console.WriteLine("Enter a Word"); 
            //Getting String(word) from Console 
            str = Console.ReadLine(); 
            //Calculate length of string str 
            Length = str.Length - 1; 
            while(Length>=0) 
            { 
                reverse = reverse + str[Length]; 
                Length--; 
            } 
            //Displaying the reverse word 
            Console.WriteLine("Reverse word is {0}",reverse); 
            Console.ReadLine(); 
        } 
    } 



Posted By: pankaj_bhakre

Give your valuable Feedback 
#चारोळी #मैत्री

जशी डोळ्यांना साथ असते पापण्यांची
तशीच चंद्राला साथ असते चांदण्यांची
जशी शरीराला साथ असते हृदयाची
तशीच साथ राहु दे तुझी माझ्याशी


Posted By :  pankaj_bhakre

My Travel History

C# Program to Get a Number and Display the Number with its Reverse
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            int num, reverse = 0;
            Console.WriteLine("Enter a Number : ");
            num = int.Parse(Console.ReadLine());
            while (num != 0)
            {
                reverse = reverse * 10;
                reverse = reverse + num % 10;
                num = num / 10;
            }
            Console.WriteLine("Reverse of Entered Number is : "+reverse);
            Console.ReadLine();

        }
    }
}


Posted By: pankaj_bhakre

Sunday 24 May 2020


Don’t listen to what they say. Go see.

Trip to Harishchandragad

1 / 8
Harishchandragad
2 / 8
Temple of Lord Shiva
3 / 8
Hoisted Flag on Fort
4 / 8
Peak Point
5 / 8
Mountain View
6 / 8
West Pier
7 / 8
Sahyadri Mountain
8 / 8
Quite Difficult to Walk

At a distance of 8 km from Khireshwar, 50 km from Bhandardara, 166 km from Pune 
& 218 km from Mumbai, Harishchandragad is a historical hill fort situated in Ahmednagar
district of Maharashtra. The height of the fort is 1,424 meters..
Harishchandragad is very popular place for trekking in Maharashtra and 
also one of the famous Bhandardara tourist places.

Travel far enough, you meet yourself

Trip to Kalsubai Mountain

1 / 8
Beautiful Village
2 / 8
Somewhere in the middle of mountain
3 / 8
Full of Greenery
4 / 8
See the Beauty
5 / 8
Greenery Fog & Me
6 / 8
Path Through the Forest
7 / 8
Slippery & Difficult Route
8 / 8
Near to Top of Mountain

Kalsubai is the highest peak of Maharashtra’s Ahmednagar district in Akola taluka. 
The summit height of the Sahyadri mountain ranges in the north is 1646 meters
(or 5400 feet).
It is known as the Everest of Maharashtra. Kalsubai Shikhar is situated on the
 border of Ahmadnagar and Nashik districts.
There is a small temple of Goddess Kisubai on the summit.

Thursday 21 May 2020

मैत्रीण

             
मैत्रीची सुरुवात कशी झाली ,
हे माहिती आहे मला तुला.
But मन जुळायला  काहीच वेळ नाही  लागला
हे माहिती आहे का तुला ?.

अंधाराच्या   काळोखात  दिसली एक वाट
तूझ्या रुपाने चालून  आली  नविन पहाट
जशी रणरणत्या उन्हात शोधत होतो सावली
तशी मैत्रीण   या  रुपाने तू येऊन भेटली

मैत्री च्या नात्याला तू कशी बघते मला नाही  माहीत
But ही मैत्री आहे माझ्यासाठी precious हे आहे का तुला माहीत ?

मैत्री म्हणजे काय ?तुला कस सांगू
शब्दांच्या व्याख्यात तुला कस बसवू
तरी सुद्धा express करतोय स्वताला
समजून घेशील या मित्राला
आपलं नात असच टिकाव म्हणून प्रार्थना करतो देवाला .

Posted By: pankaj_bhakre
#चारोळी#मैत्री#प्रेम

एक एक थेंबापासून बनलेलं  ढग  आहे मी ,
त्यापासून  बरसणारं पाणी  आहेस  तू.
एक एक जुळवलेला शब्द आहे मी ,
त्यापासून तैयार झालेली कविता आहेस तू.

Posted By : pankaj_bhakre

Wednesday 20 May 2020

#शायरी

दिल मे एक आस है मुलाखात की
लेकिन वो भी नसीब नही हो पाती
घंटो बाते होती है phone पर
लेकिन face to face एक बात तक नही हो पाती

Posted By: pankaj_bhakre
#शायरी #यादें

ये जो बेमौसम  बारीश  हो  रही इसका  कारण  क्या  बताएं
सिने  में जो  दब गए , हो जज़्बाद क्या बताएं
कुछ पुरानी  बाते और नए सपने ,हमें सोने क्यों नहीं देती क्या बताएं
आप खुद  ही समज लीजिये , हर  बात क्या बताएं

Posted By: pankaj_bhakre
#Corona#StayHome#StaySafe

बेवजह घर से निकलने की जरूरत क्या है
युही मौत से मिलने की जरूरत क्या है
सबको पता है बाहर corona जैसा कातिल खडा है
फिर उस कातिल से मिलने की जरूरत क्या है

Posted By: pankaj_bhakre

Tuesday 19 May 2020

Ek-Jaan

शायद मेरे अल्फाज कम पड जाये,
पर तुम मेरे खामोशी को पहचान लेना.
कभी नाराज भी हो जाऊ तुझसे
तो मेरे दिल की पुकार सून लेना.

माना तेरा प्यार समंदर जैसा है
पर उसमे मीलने वाले मेरे 2
मीठे बुंद को पहचान लेना
कभी सामना करना पडा मुश्किलो का,
तो तेरे साथ खडा हू हमेशा ये जान लेना
हम तो अनजान थे एक दुसरे के लीये
लेकीन हमेशा Ek-Jaan रहेंगे ये मत भुलना


Posted By: pankaj_bhakre

Welcome to My Blog



Hello All,

I’m an accidental blogger and an Electrical engineer by education. I
started my blog just for learning something new. Professionally I am 
an IT Engineer. I never Imagined that my hobby will become my passion.
Eventually my reading skills encourage me to write Shayari's & Poems.
This blog is for those readers who loves poems, shayari & also for those
 who belongs to dotnet. I wanted my blog to be available to as many readers 
as possible , So I decided to post some technical articles on Frontend & Backend Technology.(like Angular, Asp.Net MVC, DotNet Core , ReactJs) 



MyPhoto_Collection