Wednesday, 27 July 2011

Condition to checking the time range

         Actually half a day I am seeking a right solution to check the time range for the hall management project.  For example the hall is booked for a meeting from 9.00 am to 11.00 am on a particular day.  If any other user try to book the hall at a time which include this time range.
        
         Here these timing are possible to crash  1. exact 9am to 11am
                                                                          2. 8.30am to 9.30 am
                                                                          3. 9.30 am to 10 am
                                                                          4. 8am to 12 pm

         We must check all of these conditions before book the hall 

         Here the solved condition in as C# program  consider extStart as existing start time extEnd as existing End time (i.e) the previous entries


sing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace conditioncheck
{
    class Program
    {
        static void Main(string[] args)
        {

            float extStart = 9, extEnd = 11;
            Console.WriteLine("The existing strat time is {0} \n End time is {1} \n", extStart, extEnd);
            Console.WriteLine("Enter the start time and end time ");
            float givenStart = float.Parse(Console.ReadLine());
            float givenEnd = float.Parse(Console.ReadLine());

            Console.WriteLine("The given strat time is {0} \n End time is {1} ", givenStart, givenEnd);
           

            if (((givenStart>=extStart)&&(givenStart<extEnd))||((givenStart<=extStart)&&(givenEnd>extStart)))
                {
                Console.WriteLine("Meeting Crashes ");
                }
                else
                {
                    Console.WriteLine("Meeting not crashes ");
                }
            Console.Read();


        }
    }
    }

Tuesday, 26 July 2011

Get Element By Id in Sharepoint

I’ve just found out that using JavaScript’s getElementById() function doesn’t quite work as expected when dealing with controls on SharePoint pages. This is because SharePoint uses its own identifiers, so TextBox1 becomes something like ctl00$ctl00$g_3f6d90e4_335b_467c_a53f_6ae00bca6b63$ctl00$TextBox1.
Fortunately there’s a simple solution – instead of the following (which will cause an “Object required” JavaScript error):
document.getElementById("TextBox1");
you need to use this, which will insert the correct full ID for the element and thus work correctly:
document.getElementById("< %=TextBox1.ClientID%>");
It gets a bit more complicated when using nested controls, which is explained in this

Tuesday, 19 July 2011

How to prevent a user to close the browser window using JavaScript

           You had seen in many sites if you are going to close the page one warning windows is displayed and ask "This page is asking you to confirm that you want to leave - data you have entered may not be saved." Leave Page or Stay.......... 

           If you need a alert like this it is very very simple by using the following code
<html>
<head>
<title> sample page</title>
<script type="text/javascript">
window.onbeforeunload=checkIt;
function checkIt()
{
 return false;
}
</script>
</head>
<body>
</body>
</html>