Archive for the ‘Software Development’ Category

Cancel Event-Bubbling in Dojo

Monday, September 28th, 2009

If you have ever worked with a set of nested div’s which needed to listen for onclick event you must surely have encountered this issue.

If child div is clicked the parent’s click event will also be triggered because of Event-Bubbling.

The Internet Explorer 4 or later and Netscape 6 event model mechanism that propagates events from the target element upward through the HTML Page.

Me and my team mate Anoop were struggling with the problem for a long time and today he finally found a solution to it.

Use the code below to cancel the Event-Bubbling.

dojo.connect(dojo.byId("myDiv"),"onmouseover",

function(evt){

//Do Something
//..
//..

evt.stopPropagation(); //Stop Event Bubbling

});

Here passing the evt paramenter is very crucial otherwise the Event Bubbling wont stop! ;-)

Post to Twitter

ASP.NET MasterPage Caching Issues

Monday, September 28th, 2009

A MasterPage is cached by the WebServer to give faster response to the user.

The caching occurs the first time it is the corresponding ContentPage is invoked.

Due to this fact the LoginView inside a Masterpage would be updated on some pages and would fail to update on others,
giving inconsistent results.

The solution to this problem is that you need to use control as seen below.

<div class="loginstatus">
      <asp:Substitution runat="server" ID="substituteLoginInfo" MethodName="methodToInvoke" />
</div>

The thing with control is that you need to point it to a static Method on the Masterpage Codebehind

It has the following signature :

public static string methodToInvoke(HttpContext context)
{
   return DateTime.Now.ToLongTimeString();
}

This method will return a HTML string that will be substituted in the page, hence the name of the control.

I read this on Scott Guthrie ‘s website and he referred to as “dough-nut cache”.

Where the cream part of the dough-nut is the substitution control which is not cached :)

Post to Twitter