Tuesday 4 November 2014

Allow only decimal numbers in the Textbox using Javascript

Javascript code:

    <script language="Javascript" type="text/javascript">
        function onlyNos(e, t) {
            try {
                if (window.event) {
                    var charCode = window.event.keyCode;
                }
                else if (e) {
                    var charCode = e.which;
                }
                else { return true; }
                if (charCode > 31 && (charCode < 48 || charCode > 57)) {
                    if (charCode === 46)
                        return true;
                    else
                        return false;
                }
                return true;
            }
            catch (err) {
                alert(err.Description);
            }
        }
    </script>

Textbox:

<asp:TextBox ID="txtNumbersOnly" runat="server" onkeypress="return onlyNos(event,this);" Width="146px" CssClass="rightinput"></asp:TextBox> 

Friday 28 March 2014

ASP.NET Page Life Cycle

When an ASP.NET page runs, the page goes through a life cycle in which it performs a series of processing steps. These include initialization, instantiating controls, restoring and maintaining state, running event handler code, and rendering. It is important for you to understand the page life cycle so that you can write code at the appropriate life-cycle stage for the effect you intend.

You can go through the entire life cycle in details at: ASP.NET Page Life Cycle Overview


Saturday 1 March 2014

What is Managed Code?

Managed code run under the control of CLR. So CLR execute this managed code.

All IL codes are managed code hence it is run under the control of CLR. And if have used any component which is not built on .NET framework then such referenced codes are called unmanaged code.

What is Common Language Runtime (CLR) in .NET?

Common Language Runtime or CLR is responsible for executing your application code and the code running under the control of CLR is also called managed code.

Any application written in any language of .Net framework will never directly compiled to machine understood code instead the compiler converts the code into a special language called MSIL (Microsoft Intermediate Language) and then CLR compile MSIL into platform-specific code.
So only the methods that are actually called during execution are compiled.

So in short, the .NET Framework understands only one language that is MSIL.

Monday 6 January 2014

How to rename database table column with new name?

You need to use the sp_rename command, or use Management Studio to do it visually. Now, to change the Column Name from "Old_Name" to "New_NameChange" we can use command:
sp_RENAME 'Table_Name.[Old_Name]', '[New_NameChange]' , 'COLUMN'

Friday 15 November 2013

What does “event bubbling” mean?

Event bubbling means that an event propagates through the ancestors of the element the event fired on.

Lets show what this means using the HTML markup below:

<div>
    <h1>
        <a href="#">
            <span>Hello</span>
        </a>
    </h1>
</div>
Lets assume we click the span, which causes a click event to be fired on the span; nothing revolutionary so far. However, the event then propagates (or bubbles) to the parent of the span (the <a>), and a click event is fired on that. This process repeats for the next parent (or ancestor) up to the document element.

You can see the live example in action here