Rafael del Corr...'s profile..:: Blog de Rafael del ...BlogLists Tools Help

Blog


    WMC Common Events

    There are certain events that all control has. Most of it are very similar to standard ASP. In the coming posts we will see properties and event of each control, for now I will describe the common events and it´s description.

    To call a method when an event occurs we must follow the following syntax:

    <mobile:Command ID="btnBoton" Runat="server" OnInit="Method1">
       Boton
    </mobile:Command>

    The name of the event must be preceded of the word “On”. It means, if we want to call a method when the Init event occurs we should write ‘OnInit=Method1’. The syntax to write a method is:

    <script runat="server">
        void Method1(object sender, EventArgs e)
        {
            btnBoton.Text = "Boton cambiado";
        }
    </script>

    The method receives two parameters: the first, is the object from where we are getting the method, and in second place,  an EventArgs type that can be used by the developer by using different optional arguments for the event.

    Now, as we said at the beginning  there common events between the WMC, and they are:

    DataBinding
    It occurs when the control is vinculated with a data source. This event ask to the server for the logical data that it is writed for him.

    Disposed
    When a control is no longer exists the last event that occurs is this. The control was disposed from memory.

    Init
    This event constitute the first stage when a control is initialized from the server.

    Load
    Occurs when the page is loaded.

    UnLoad
    This event occurs when the page in unloaded.

    PreRender
    This event occurs after the page is loaded, but before the page is rendered. This method can be used, for example, when you want to make a change in the ViewState property of any control, like this (try this example in a new website):

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <body>
        <mobile:Form id="Form1" runat="server">
            <mobile:Command ID="btnBoton1" Runat="server" OnPreRender="Method1">
                Boton
            </mobile:Command>
        </mobile:Form>   

        <script runat="server">
            void Method1(object sender, EventArgs e)
            {
                btnBoton1.EnableViewState = false;
            }
        </script>
    </body>
    </html>

    Well, today we talked about the common events of the WMC´s. In the followings posts we will see each control specifically, their properties, events and methods.

    See you soon.

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://mobiledevp.spaces.live.com/blog/cns!B1F45CF18768D48A!118.trak
    Weblogs that reference this entry
    • None