Archive for August 17th, 2011

Javascript with ASP.NET Master Page

I faced difficulties while using javascript in Web Form with Master Page. I was trying to use a Javascript Calender in asp.net page and this requires the FORM name and CONTROL name to initiate the calender. So, I started with the following code snippet.

                
new tcal ({
'formname': 'Form1',
'controlname': 'dateTextBox'				
});			 

Continue reading

Javascript to disable Right Click

This is an handy script to disable right click in webpages. Just put this script in between javascript tag and have right click disabled on your webpage.


     var message="Sorry, Right Click is disabled.";
   //To disable the right click on the page
    function click(e) 
    {
        if (document.all)
         {
            if (event.button == 2) 
            {
            alert(message);
            return false;
            }
         }
        if (document.layers) 
         {
            if (e.which == 3) 
            {
            alert(message);
            return false;
            }
         }
    }
    if (document.layers) 
    {
        document.captureEvents(Event.MOUSEDOWN);
    }
    document.onmousedown=click;

Thanks
A Rahim Khan