Friday 19 July 2013

How .net application executes

Windows (the OS) will be running at Start; the CLR won't begin execution until Windows starts it. When an application executes, OS inspects the file to see whether it has a special header to indicate that it is a .NET application. If not, Windows continues to run the application.

If an application is for .NET, Windows starts up the CLR and passes the application to the CLR for execution. The CLR loads the executable assembly, finds the entry point, and begins its execution process.

The executable assembly could reference other assemblies, such as dynamic link libraries (DLLs), so the CLR will load those. However, this is on an as-needed basis. An assembly won't be loaded until the CLR needs access to the assembly's code. It's possible that the code in some assemblies won't be executed, so there isn't a need to use resources unless absolutely necessary.

As mentioned previously, the C# compiler produces IL as part of an assembly's output. To execute the code, the CLR must translate the IL to binary code that the operating system understands. This is the responsibility of the JIT compiler.

As its name implies, the JIT compiler only compiles code before the first time that it executes. After the IL is compiled to machine code by the JIT compiler, the CLR holds the compiled code in a working set. The next time that the code must execute, the CLR checks its working set and runs the code directly if it is already compiled. It is possible that the working set could be paged out of memory during program execution, for various reasons that are necessary for efficient operation of the CLR on the particular machine it is running on. If more memory is available than the size of the working set, the CLR can hold on to the code. Additionally, in the case of Web applications where scalability is an issue, the working set can be swapped out due to periodic recycling or heavier load on the server, resulting in additional load time for subsequent requests.

The JIT compiler operates at the method level. If you aren't familiar with the term method, it is essentially the same as a function or procedure in other languages. Therefore, when the CLR begins execution, the JIT compiler compiles the entry point (the Main method in C#). Each subsequent method is JIT compiled just before execution. If a method being JIT compiled contains calls to methods in another assembly, the CLR loads that assembly (if not already loaded).

This process of checking the working set, JIT compilation, assembly loading, and execution continues until the program ends.

The meaning to you in the CLR execution process is in the form of application design and understanding performance characteristics. In the case of assembly loading, you have some control over when certain code is loaded. For example, if you have code that is seldom used or necessary only in specialized cases, you could separate it into its own DLL, which will keep the CLR from loading it when not in use. Similarly, separating seldomly executed logic into a separate method ensures the code doesn't JIT until it's called.

Another detail you might be concerned with is application performance. As described earlier, code is loaded and JIT compiled. Another DLL adds load time, which may or may not make a difference to you, but it is certainly something to be aware of. By the way, after code has been JIT compiled, it executes as fast as any other binary code in memory.

One of the CLR features listed in Table 1.1 is .NET Framework Class Library (FCL) support. The next section goes beyond FCL support for the CLR and gives an overview of what else the FCL includes.

Monday 11 March 2013

How to implement pagging in Repeater OR Datalist



Repeater and DataList control does not provide default pagging so we need to implement it explicitly. this is very easy to implement our own pagging in Repeater or Datalist.
   Just follow the step and your pagging will implement very easily :

Step 1.  
           Follow these step for .aspx page:
         i. Copy and paste in .aspx page where you want to display Repeater Or DataList data
======================================================================

 <table>
                        <tr>
                            <td>
                                <asp:Repeater ID="dListItems" runat="server">
                                    <ItemTemplate>
                                        <asp:Label ID="Label1" runat="server" Text='<%#Eval("title") %>'></asp:Label>
                                        <br />
                                    </ItemTemplate>
                                </asp:Repeater>
                            </td>
                        </tr>
                    </table>
======================================================================
ii. Copy and paste this where you want display pagging in your page 
======================================================================

    <table>
                            <tr>
                                <td>
                                    <asp:LinkButton ID="lbtnFirst" OnClick="lbtnFirst_Click" runat="server">First</asp:LinkButton>&nbsp;<asp:LinkButton
                                        ID="lbtnPrevious" OnClick="lbtnPrevious_Click" runat="server"><<</asp:LinkButton>&nbsp;
                                </td>
                                <td>
                                    <asp:DataList ID="dlPaging" RepeatDirection="Vertical" RepeatColumns="10" runat="server"
                                        OnItemDataBound="dlPaging_ItemDataBound" OnItemCommand="dlPaging_ItemCommand">
                                        <ItemTemplate>
                                            <asp:LinkButton ID="lnkbtnPaging" Text='<%#Eval("PageText") %>' CommandArgument='<%#Eval("PageIndex") %>'
                                                CommandName="Paging" runat="server">LinkButton</asp:LinkButton>
                                        </ItemTemplate>
                                    </asp:DataList>
                                </td>
                                <td>
                                    &nbsp;<asp:LinkButton ID="lbtnNext" OnClick="lbtnNext_Click" runat="server">>></asp:LinkButton>&nbsp;<asp:LinkButton
                                        ID="lbtnLast" OnClick="lbtnLast_Click" runat="server">Last</asp:LinkButton>
                                </td>
                            </tr>
                        </table>
======================================================================
iii. Copy and paste this where you want to display pagging info (i.e.currently displaying which number of page, total pages etc...)
======================================================================
 <asp:Label ID="lblPageInfo" runat="server" Text="Label"></asp:Label> ======================================================================
Above provided steps are for .aspx page .
now next step is for .aspx.cs page means for code behind.
Step 2:
          just and paste these function in code behind and run your page.
i. copy these all functions and paste in code behind : 
=======================================================================

 /// <summary>
    /// This will bind data into datalist
    /// </summary>
    private void BindItemsList()
    {
        PagedDataSource _PageDataSource = new PagedDataSource();

        DataTable dataTable = this.GetDataTable();
        _PageDataSource.DataSource = dataTable.DefaultView;
        _PageDataSource.AllowPaging = true;
        _PageDataSource.PageSize = 10;
        _PageDataSource.CurrentPageIndex = CurrentPage;
        ViewState["TotalPages"] = _PageDataSource.PageCount;

        this.lblPageInfo.Text = "Page " + (CurrentPage + 1) + " of " + _PageDataSource.PageCount;
        this.lbtnPrevious.Enabled = !_PageDataSource.IsFirstPage;
        this.lbtnNext.Enabled = !_PageDataSource.IsLastPage;
        this.lbtnFirst.Enabled = !_PageDataSource.IsFirstPage;
        this.lbtnLast.Enabled = !_PageDataSource.IsLastPage;

        this.dListItems.DataSource = _PageDataSource;
        this.dListItems.DataBind();
        this.doPaging();
    }
    /// <summary>
    /// Praparing table for filling into datalist
    /// </summary>
    /// <returns>Datatable</returns>
    private DataTable GetDataTable()
    {
        DataTable dtItems = new DataTable();

        DataColumn dcName = new DataColumn();
        dcName.ColumnName = "title";
        dcName.DataType = System.Type.GetType("System.String");
        dtItems.Columns.Add(dcName);

        DataRow row;
        for (int i = 1; i <= 100; i++)
        {
            row = dtItems.NewRow();
            row["title"] = "Sample Text: this is sample text " + i;
            dtItems.Rows.Add(row);

        }
        return dtItems;

    }
    /// <summary>
    /// Property
    /// </summary>
    private int CurrentPage
    {
        get
        {
            object objPage = ViewState["_CurrentPage"];
            int _CurrentPage = 0;
            if (objPage == null)
            {
                _CurrentPage = 0;
            }
            else
            {
                _CurrentPage = (int)objPage;
            }
            return _CurrentPage;
        }
        set { ViewState["_CurrentPage"] = value; }
    }
    /// <summary>
    /// Property
    /// </summary>
    private int fistIndex
    {
        get
        {

            int _FirstIndex = 0;
            if (ViewState["_FirstIndex"] == null)
            {
                _FirstIndex = 0;
            }
            else
            {
                _FirstIndex = Convert.ToInt32(ViewState["_FirstIndex"]);
            }
            return _FirstIndex;
        }
        set { ViewState["_FirstIndex"] = value; }
    }
    /// <summary>
    /// Property
    /// </summary>
    private int lastIndex
    {
        get
        {

            int _LastIndex = 0;
            if (ViewState["_LastIndex"] == null)
            {
                _LastIndex = 0;
            }
            else
            {
                _LastIndex = Convert.ToInt32(ViewState["_LastIndex"]);
            }
            return _LastIndex;
        }
        set { ViewState["_LastIndex"] = value; }
    }
    /// <summary>
    /// Fill pages with link in paggingdatalist
    /// </summary>
    private void doPaging()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("PageIndex");
        dt.Columns.Add("PageText");

        fistIndex = CurrentPage - 5;

        if (CurrentPage > 5)
        {
            lastIndex = CurrentPage + 5;
        }
        else
        {
            lastIndex = 10;
        }
        if (lastIndex > Convert.ToInt32(ViewState["TotalPages"]))
        {
            lastIndex = Convert.ToInt32(ViewState["TotalPages"]);
            fistIndex = lastIndex - 10;
        }

        if (fistIndex < 0)
        {
            fistIndex = 0;
        }

        for (int i = fistIndex; i < lastIndex; i++)
        {
            DataRow dr = dt.NewRow();
            dr[0] = i;
            dr[1] = i + 1;
            dt.Rows.Add(dr);
        }

        this.dlPaging.DataSource = dt;
        this.dlPaging.DataBind();
    }
    protected void dlPaging_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName.Equals("Paging"))
        {
            CurrentPage = Convert.ToInt16(e.CommandArgument.ToString());
            this.BindItemsList();
        }
    }

    protected void dlPaging_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        LinkButton lnkbtnPage = (LinkButton)e.Item.FindControl("lnkbtnPaging");
        if (lnkbtnPage.CommandArgument.ToString() == CurrentPage.ToString())
        {
            lnkbtnPage.Enabled = false;
            lnkbtnPage.Style.Add("fone-size", "14px");
            lnkbtnPage.Font.Bold = true;

        }
    }
    protected void lbtnNext_Click(object sender, EventArgs e)
    {
        CurrentPage += 1;
        this.BindItemsList();
    }
    protected void lbtnPrevious_Click(object sender, EventArgs e)
    {
        CurrentPage -= 1;
        this.BindItemsList();
    }
    protected void lbtnLast_Click(object sender, EventArgs e)
    {

        CurrentPage = (Convert.ToInt32(ViewState["TotalPages"]) - 1);
        this.BindItemsList();

    }
    protected void lbtnFirst_Click(object sender, EventArgs e)
    {
        CurrentPage = 0;
        this.BindItemsList();
    }
====================================================================
ii. this is last step just call this function in page_load()


 if (!IsPostBack)
        {
            this.BindItemsList();
        }

Pagging preview :
your pagging will look like ....





Thursday 7 February 2013

Work on Your own Field rather then following somebody else

One mind blowing interview

Interviewer : Tell me about yourself.

Candidate: I ...am Rameshwar Kulkarni. I did my Tele Communication engineering from BabanRao Dhole-Patil Inst it ute of Technology.

Interviewer : BabanRao Dhole-Patil Inst it ute of Technology? I had never heard of this college before!
Candidate : Great! Even I had not heard of it before getting an admission into it ..
What happened is – due to cricket world cup I scored badly! in 12th.I was getting a paid seat in a good college. But my father said (I prefer to call him ‘baap’) – “I can not invest so much of money”.(The baap actually said – “I will never waste so much of money on you”). So I had to join this college. Frankly speaking this name – BabanRao Dhole-Patil, can at the most be related to a Shetakari Mahavidyalaya

Interviewer: ok, ok. It seems you have taken 6 years to complete your engineering.
Candidate : Actually I tried my best to finish it in 4 years. But you know, these cricket matches and football world cup, and tennis tournaments. It is difficult to concentrate. So I flunked in 2nd and 3rd year. So in all I took 4 + 2 = 7 years.

Interviewer: But 4+2 is 6.
Candidate: Oh, is it ? You know I always had KT in maths. But I will try to keep this in mind. 4+2 is 6, good, thanks. These cricket matches really affect exams a lot.. I think they should ban it .

Interviewer : Good to know that you want cricket matches to be banned.
Candidate : No, no… I am talking about Exams!!

Interviewer: Ok, What is your biggest achievement in life?
Candidate : Obviously, completing my Engineering. My mom never thought I would complete it . In fact, when I flunked in 3rd year, she was looking for a job for me in BEST (Bus
corporation in Maharashtra ) through some relative.

Interviewer : Do you have any plans of higher study?
Candidate: he he he.. Are you kidding? Completing ‘lower’ education it self was so much of pain!!

Interviewer : Let’s talk about technical stuff. On which platforms have you worked?
Candidate : Well, I work at SEEPZ, so you can say Andheri is my current platforms. Earlier I was at Vashi center. So Vashi was my platform then. As you can see I have experience of different platforms! (Vashi and Andheri are the places in Mumbai)

Interviewer : And which languages have you used?
Candidate : Marathi, Hindi, English. By the way, I can keep quiet in German, French, Russian and many other languages.

Interviewer: Why VC is better than VB?
Candidate : It is a common sense – C comes after B. So VC is a higher version than VB. I heard very soon they are coming up w it h a new language VD!

Interviewer: Do you know anything about Assembly Language?
Candidate: Well, I have not heard of it . But I guess, this is the language our ministers and MPs use in assembly.

Interviewer : What is your general project experience?
Candidate : My general experience about projects is – most of the times they are in pipeline!

Interviewer: Can you tell me about your current job?
Candidate: Sure, Currently I am working for Bata Info Tech ltd. Since joining BIL, I am on Bench. Before joining BIL, I used to think that Bench was another software like Windows.

Interviewer : Do you have any project management experience?
Candidate: No, but I guess it shouldn’t be difficult. I know Word and Excel. I can talk a lot. I know how to dial for International phone call and use speaker facility. And very important – I know few words like – ‘Showstoppers ‘ , ‘hot fixes’, ‘SEI-CMM’, ‘quality’, ‘version control’, ‘deadlines’ , ‘Customer Satisfaction’ etc. Also I can blame others for my mistakes!

Interviewer: What are your expectations from our company?
Candidate : Not much.
1. I should at least get 40,000 in hand..
2. I would like to work on a live EJB project. But it should not have deadlines. I personally feel that pressure affects natural talent.
3. I believe in flexi-timings.
4. Dress Code is against basic freedom, so I would like to wear t-shirt and jeans.
5. We must have sat-sun off. I will suggest Wednesday off also, so as to avoid breakdown due to overwork.
6. I would like to go abroad 3 times a year on short term preferably 1-2 months) assignments. Personally I prefer US, Australia and Europe. But considering the fact that there are Olympics coming up in China in the current year, I don’t mind going there in that period. As you can see I am modest and don’t have many expectations. So can I assume my selection?

Interviewer : he he he ha ha ha. Thanks for your interest in our
organization. In fact I was never entertained so much before. Welcome to INFOSYS.

The fellow was appointed in a newly created section ‘Stress Management’ in the HRD of Infosys.

So Excellence is not the only thing Needed. Its the Unique Quality of a Person which can let anyone to Success.
One mind blowing interview

Interviewer : Tell me about yourself.
Candidate: I ...am Rameshwar Kulkarni. I did my Tele Communication engineering from BabanRao Dhole-Patil Inst it ute of Technology.

Interviewer : BabanRao Dhole-Patil Inst it ute of Technology? I had never heard of this college before!
Candidate : Great! Even I had not heard of it before getting an admission into it ..
What happened is – due to cricket world cup I scored badly! in 12th.I was getting a paid seat in a good college. But my father said (I prefer to call him ‘baap’) – “I can not invest so much of money”.(The baap actually said – “I will never waste so much of money on you”). So I had to join this college. Frankly speaking this name – BabanRao Dhole-Patil, can at the most be related to a Shetakari Mahavidyalaya

Interviewer: ok, ok. It seems you have taken 6 years to complete your engineering.
Candidate : Actually I tried my best to finish it in 4 years. But you know, these cricket matches and football world cup, and tennis tournaments. It is difficult to concentrate. So I flunked in 2nd and 3rd year. So in all I took 4 + 2 = 7 years.

Interviewer: But 4+2 is 6.
Candidate: Oh, is it ? You know I always had KT in maths. But I will try to keep this in mind. 4+2 is 6, good, thanks. These cricket matches really affect exams a lot.. I think they should ban it .

Interviewer : Good to know that you want cricket matches to be banned.
Candidate : No, no… I am talking about Exams!!

Interviewer: Ok, What is your biggest achievement in life?
Candidate : Obviously, completing my Engineering. My mom never thought I would complete it . In fact, when I flunked in 3rd year, she was looking for a job for me in BEST (Bus
corporation in Maharashtra ) through some relative.

Interviewer : Do you have any plans of higher study?
Candidate: he he he.. Are you kidding? Completing ‘lower’ education it self was so much of pain!!

Interviewer : Let’s talk about technical stuff. On which platforms have you worked?
Candidate : Well, I work at SEEPZ, so you can say Andheri is my current platforms. Earlier I was at Vashi center. So Vashi was my platform then. As you can see I have experience of different platforms! (Vashi and Andheri are the places in Mumbai)

Interviewer : And which languages have you used?
Candidate : Marathi, Hindi, English. By the way, I can keep quiet in German, French, Russian and many other languages.

Interviewer: Why VC is better than VB?
Candidate : It is a common sense – C comes after B. So VC is a higher version than VB. I heard very soon they are coming up w it h a new language VD!

Interviewer: Do you know anything about Assembly Language?
Candidate: Well, I have not heard of it . But I guess, this is the language our ministers and MPs use in assembly.

Interviewer : What is your general project experience?
Candidate : My general experience about projects is – most of the times they are in pipeline!

Interviewer: Can you tell me about your current job?
Candidate: Sure, Currently I am working for Bata Info Tech ltd. Since joining BIL, I am on Bench. Before joining BIL, I used to think that Bench was another software like Windows.

Interviewer : Do you have any project management experience?
Candidate: No, but I guess it shouldn’t be difficult. I know Word and Excel. I can talk a lot. I know how to dial for International phone call and use speaker facility. And very important – I know few words like – ‘Showstoppers ‘ , ‘hot fixes’, ‘SEI-CMM’, ‘quality’, ‘version control’, ‘deadlines’ , ‘Customer Satisfaction’ etc. Also I can blame others for my mistakes!

Interviewer: What are your expectations from our company?
Candidate : Not much.
1. I should at least get 40,000 in hand..
2. I would like to work on a live EJB project. But it should not have deadlines. I personally feel that pressure affects natural talent.
3. I believe in flexi-timings.
4. Dress Code is against basic freedom, so I would like to wear t-shirt and jeans.
5. We must have sat-sun off. I will suggest Wednesday off also, so as to avoid breakdown due to overwork.
6. I would like to go abroad 3 times a year on short term preferably 1-2 months) assignments. Personally I prefer US, Australia and Europe. But considering the fact that there are Olympics coming up in China in the current year, I don’t mind going there in that period. As you can see I am modest and don’t have many expectations. So can I assume my selection?

Interviewer : he he he ha ha ha. Thanks for your interest in our
organization. In fact I was never entertained so much before. Welcome to INFOSYS.

The fellow was appointed in a newly created section ‘Stress Management’ in the HRD of Infosys.

So Excellence is not the only thing Needed. Its the Unique Quality of a Person which can let anyone to Success. Work on Your own Field rather then following somebody else's Path
Share this Story with your Friends and Inspire People ♥♥♥
else's Path
Share this Story with your Friends and Inspire People ♥♥♥