View Single Post
  #1 (permalink)  
Old January 21st, 2008, 03:08 PM
Kika Kika is offline
Registered User
 
Join Date: Nov 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Avoid postback when a ComboBox is clicked

Hi All,

I have a custom Control which contains div as a main container and any other control can be dragged and dropped within the div control. Currently, I have added client side code to invoke a postback on the following events of the container:
        document.onchange = handleEvent;
        interceptor.onclick = handleEvent;
        interceptor.onkeypress = handleEvent;
        interceptor.onkeyup = handleEvent;
        interceptor.onpaste = handleEvent;

So in any of these events on the container or any its child a postback event is raised to the server with the function handleEvent:

function handleEvent(event)
 {
    var btsave = document.getElementById(controlEtatUpdate);

    if ( btsave.disabled )
    {
        if (!event)
        {
            var e = window.event;
            if (!e.ctrlKey)
            {
                if (e.keyCode != Sys.UI.Key.tab)
                {
                    if (e.srcElement.type) {
                        if (e.srcElement.type == 'text')
                        {
                            if (e.type != 'click')
                            {
                                // Save the current position for a text.
                                currentPosition = getPosition(e.srcElement)

                                WarnServer();
                            }
                        }
                        else
                        {
                            WarnServer();
                        }

                        //W3C model
                        if (e.stopPropagation)
                        {
                            e.stopPropagation();
                        }
                    }
                }
            }
        }
    }
}


So as soon you click on the custom control, an even is raised but I would like to avoid that in the case of a ComboBox…Especially when there is no change in the selection. Any help will appreciated.


Reply With Quote