Monday, June 25, 2012

Windows 8 Metro: Asynchrony made easy


 After the birth of Silverlight the developers have had to deal with asynchronous programming much more than before. The responsiveness of the user interface has always been an important matter and asynchronous programming has been the right response also before than Silverlight, in Windows Forms and WPF. But for the first time, Silverlight made a strict request by the framework to run a lot of tasks asynchronous. Due to architectural choices, all the calls to the network API had to be made in an async way, and this caused a number of headaches to developers that for the very first time couldn't forget about asynchronicity paying the price of a bad user experience.

In metro-style applications, the concept of "make it asynchronous" is exploded to the extreme consequences. WinRT, the underlying wrapper for Windows API, request to run asynchronously most of the tasks, with the rule that, if it may run longer than 50 milliseconds, then it has to be asynchronous. Calling the network, using a device, grabbing a photo from the camera, all these actions are asynchronous in metro-style applications but, async is hidden also behind simpler tasks like opening a message box.
All this surfeit of asynchronous, promises to make programmer's life a hell. Luckily, the .NET framework 4.5 introduces a set of tools to the rescue, making asynchronous simpler as drinking a glass of water.


Read More

Wednesday, June 20, 2012

Microsoft Announces Surface: Tablet PC

LOS ANGELES — June 18, 2012 — Today at an event in Hollywood, Microsoft unveiled Surface: PCs built to be the ultimate stage for Windows. Company executives showed two Windows tablets and accessories that feature significant advances in industrial design and attention to detail. Surface is designed to seamlessly transition between consumption and creation, without compromise. It delivers the power of amazing software with Windows and the feel of premium hardware in one exciting experience. 
Conceived, designed and engineered entirely by Microsoft employees, and building on the company’s 30-year history manufacturing hardware, Surface is designed to seamlessly transition between consumption and creation, without compromise.
Surface: A New Family of PCs for Windows
June 19, 2012
Conceived, designed and engineered entirely by Microsoft employees, and building on the company’s 30-year history manufacturing hardware, Surface is designed to seamlessly transition between consumption and creation, without compromise.

Android Ported to C#


Oracle and Google are currently in a $1 billion wrestling match over Google’s use of Java in Android.
But Java is not the only way to build native apps on Android. In fact, it’s not even the best way: we have been offering C# to Android developers as a high-performance, low-battery consuming alternative to Java. Our platform, Mono, is an open source implementation of the .NET framework that allows developers to write their code using C# while running on top of the Java-powered operating system, and then share that same code with iOS and Windows Phone.
Unlike Sun with Java, Microsoft submitted C# and the .NET VM for standardization to ECMA and saw those standards graduated all the way to ISO strong patent commitments. The .NET framework is also covered by Microsoft’s legally binding community promise.
Last July when Xamarin was getting started, we got our team together in Boston to plan the evolution of Mono on iOS and Android. After a day of kayaking in the Charles River, we sat down to dinner and turned our attention to how we could improve the performance and battery life of applications on Android, and make our own Mono for Android even better.

Read more

No Java Required: Write Android Apps in C#

Java is the underlying code for the Android OS. But one company has changed all that, ripping out most of the Java and replacing it with C#.
That means .NET developers can code in a familiar language and produce apps that leverage C#'s advantages, including speed increases.
It started as a skunkworks project for Xamarin. Xamarin's claim to fame is Mono, an open-source framework allowing Android and iOS apps to be built using C# running on top of Java. Now, with what the company calls the XobotOS Research Project, the Java layer has been removed via a "machine translation of Android from Java to C#," according to ablog post from Xamarin CTO Miguel de Icaza.

Monday, June 18, 2012

Javascript Regular Expression validation For Email

 function validate(email) {
        var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        return reg.test(email);
    }

 Here you need to pass the email address as parameter.

 function validateEmail(sender, args) {
        var isValid = 1;
        var strEmails = document.getElementById("<%= txtEmailAddress.ClientID %>").value;
        var emails = strEmails.split(";");
        for (i = 0; i < emails.length; i++) {
            if (!validate(trim(emails[i]))) {
                isValid = -1;
                break;
            }
        }
        if (isValid == -1) {
            args.IsValid = false;
        }
        else {
            args.IsValid = true;
        }
    }

txtEmailAddress is the rich text box. This function is the asp custom validator function

Friday, June 15, 2012

Create Table With Culustered And Non- Clustered Index


CREATE TABLE Vehicle(
    ID INT IDENTITY(1,1) NOT NULL,
    VendorID INT  NOT NULL,
    CampaignName VARCHAR(50) NOT NULL,
    StartDate DATETIME  NOT NULL ,
    EndDate    DATETIME  NOT NULL ,
    NationalAmount NUMERIC(4,2) NULL,
    NationalOperator INT NULL,
    InternationalAmount    NUMERIC(4,2) NULL,
    InternationalOperator INT NULL,
    MakeRef VARCHAR(50) NOT NULL,
    ModelRef VARCHAR(50) NULL,
    DerivativeRef VARCHAR(50) NULL,
    BodyStyleRef VARCHAR(50) NULL,
    TransmissionID INT NULL,
    ColourID INT NULL,
    FuelTypeID INT NULL,
    EngineSize INT NULL,
    AgeFrom    INT NULL,
    AgeTo INT NULL,
    AgeUnit    INT NULL,
    DamageAmountFrom INT NULL,
    DamageAmountTo    INT NULL,
    VehicleSourceID    INT NULL,
    StockAgeFrom INT NULL,
    StockAgeTo INT NULL,
    CreatedBy INT NOT NULL,
    ModifiedBy INT NULL,
    CreatedDate DATETIME NOT NULL CONSTRAINT [Vehicle_CreateDate] DEFAULT (getdate()),
    ModifiedDate DATETIME NULL,
    IsActive BIT NOT NULL CONSTRAINT [Vehicle_IsActive] DEFAULT ((1))
    CONSTRAINT [PK_Vehicle] PRIMARY KEY CLUSTERED
    (
    [ID] ASC
    )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO

-- Create the indexes
CREATE NONCLUSTERED INDEX [IX_Vehicle_VendorID] ON [dbo].[Vehicle]
(
    VendorID ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
CREATE NONCLUSTERED INDEX [IX_Vehicle_VehicleSourceID] ON [dbo].[Vehicle]
(
    VehicleSourceID ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
CREATE NONCLUSTERED INDEX [IX_VehicleCampaign_CreatedBy] ON [dbo].[Vehicle]
(
    [CreatedBy] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
CREATE NONCLUSTERED INDEX [IX_Vehicle_ModifiedBy] ON [dbo].[Vehicle]
(
    [ModifiedBy] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO

Creating A Trigger In SQL

CREATE TRIGGER [dbo].[TrTermCondition] ON [dbo].[TermCondition]
FOR INSERT, UPDATE, DELETE
AS

DECLARE @VendorID AS INT

    IF EXISTS (SELECT 1 FROM INSERTED)
    BEGIN
        SELECT  @VendorID = VendorID                  
        FROM    INSERTED       
           
        UPDATE    BUYER
        SET        IsSalesTermsAccepted = 0,
                ModifiedDt = getDate(),
                ModifiedUserID = 55   
        FROM    Buyer B               
            INNER JOIN VendorBuyers VB ON VB.BuyerID = B.ID   
           
        WHERE    VB.VendorID = @VendorID                       
    END

SQL Join, Cross Apply, Cross Join and Replace

--CREATE TABLE department
--(
--    DepartmentID INT,
--    DepartmentName VARCHAR(20)
--);

--CREATE TABLE employee
--(
--    LastName VARCHAR(20),
--    DepartmentID INT
--);

--INSERT INTO department(DepartmentID, DepartmentName) VALUES(31, 'Sales');
--INSERT INTO department(DepartmentID, DepartmentName) VALUES(33, 'Engineering');
--INSERT INTO department(DepartmentID, DepartmentName) VALUES(34, 'Clerical');
--INSERT INTO department(DepartmentID, DepartmentName) VALUES(35, 'Marketing');

--INSERT INTO employee(LastName, DepartmentID) VALUES('Rafferty', 31);
--INSERT INTO employee(LastName, DepartmentID) VALUES('Jones', 33);
--INSERT INTO employee(LastName, DepartmentID) VALUES('Steinberg', 33);
--INSERT INTO employee(LastName, DepartmentID) VALUES('Robinson', 34);
--INSERT INTO employee(LastName, DepartmentID) VALUES('Smith', 34);
--INSERT INTO employee(LastName, DepartmentID) VALUES('John', NULL);

SELECT * FROM employee INNER JOIN department ON employee.DepartmentID = department.DepartmentID;

SELECT * FROM employee JOIN department ON employee.DepartmentID = department.DepartmentID;

SELECT * FROM employee NATURAL JOIN department ON employee.DepartmentID = department.DepartmentID;
SELECT * FROM employee CROSS JOIN department where employee.LastName=Jones;

SELECT * FROM employee

SELECT * FROM department

SELECT e.*,d.* FROM employee e full outer JOIN department d ON e.DepartmentID = d.DepartmentID
 where d.DepartmentID is null and e.DepartmentID is null;

SELECT * FROM employee RIGHT  JOIN department ON employee.DepartmentID = department.DepartmentID;


SELECT RIGHT(LTRIM(RTRIM(value1)),3) , value2, MAX(location), MAX(date), MAX(category),
 SUM(debitamount), SUM(creditamount) FROM table1 GROUP BY RIGHT(LTRIM(RTRIM(value1)),3), value2

 select RIGHT(LTRIM(RTRIM(LastName)),3) from employee where DepartmentID=31
  select RIGHT(RTRIM(LastName),2) from employee where DepartmentID=31
select Left(RTRIM(LTRIM(LastName)),3) from employee where DepartmentID=31

select * from employee group by Departmentid


create table testtable (id int identity(1,1), PersonID int,    Unit varchar(10))
insert into testtable values (1,'Che')
insert into testtable  values (2,'Mat')
insert into testtable  values (1,'Phy')
insert into testtable values (2,'Che2')
insert into testtable  values (2,'Mat2')
insert into testtable  values (2,'Phy2')
insert into testtable  values (3,'Phy3')


SELECT t1.PersonID,
       Units =REPLACE( (SELECT Unit AS [data()]
           FROM testtable t2
          WHERE t2.PersonID = t1.PersonID
          ORDER BY Unit
            FOR XML PATH('')
            ), ' ', ',,')
      FROM testtable t1
      GROUP BY PersonID ;
select * from employee


select LastName,DepartmentID from employee

SELECT e1.DepartmentID,
  DepartmentID=replace((SELECT LastName AS [data()]
    FROM employee e2 WHERE e2.DepartmentID=e1.DepartmentID  ORDER BY DepartmentID
    FOR XML PATH('')),' ',',')FROM employee e1 GROUP BY DepartmentID   



SELECT  t1.*, t2o.*
FROM    t1
CROSS APPLY
        (
        SELECT  TOP 3 *
        FROM    t2
        WHERE   t2.t1_id = t1.id
        ORDER BY
                t2.rank DESC
        ) t2o
   SELECT * from employee cross join department    
       
SELECT  employee.*, department.* FROM    employee
CROSS APPLY
        (
        SELECT  *
        FROM    department
        --WHERE   department.DepartmentID = employee.DepartmentID       
        where employee.LastName='Rafferty') department


SELECT * FROM    employee
CROSS APPLY
        (
        SELECT  *
        FROM    department
        --WHERE   department.DepartmentID = employee.DepartmentID       
        where department.departmentName='sales') department
       
        select * from Employee
        CROSS APPLY
        (select * from department where department.departmentname='sales')department
       
        create table sample
        (s_id int identity(1,1) primary key,
         s_Name varchar(10),
         s_Price int,
         s_product varchar(29),
          constraint candidate_price UNIQUE(s_Price))
         
         
             create table sample2
        (s_id int identity(1,1) primary key,
         s_Name varchar(10),
         s_Price int,
         s_product varchar(29),
          constraint chck_sample check(s_Price>10))
         
          insert into sample2(s_Name,s_Price,s_product)
      
        
         
          select  'Manu',5,'pen'
          union all
         
          select  'Raj',6,'pen'
         
select @@MAX_CONNECTIONS

select @@SERVERNAME

Thursday, June 14, 2012

Disable Paste functionality of the textbox

We can disable paste functionality of the textbox by using the following code

 onpaste="javascript:return false;"

eg:    <asp:TextBox ID="txtName" runat="server" CssClass="inputText" onpaste="javascript:return false;"></asp:TextBox>    

Tuesday, June 12, 2012

Jquery functions to check all and uncheck header

I have a page with repeater in it. The repeater header contains a checkbox and all rows contains  check boxes.








I want to select the all the check boxes when i click on the header check box. and i want to remove the headec check, if i uncheck any checkbox.
here is the code.

  function UncheckHeader(header) {
        $('#divVOIUserPool input:checkbox').each(function() {
            if (!$(this).is(':checked')) {              
                $('#' + header).removeAttr('checked');
            }
        });
    }

    function CheckAll(checkbox) {
        $('#divVOIUserPool input:checkbox').each(function() {
            if (!$(this).is(':disabled')) {
                this.checked = checkbox.checked;
            }
        });
    }

Simple i ve put one div as outer to the repeater and named it as 'divVOIUserPoo', and added the properties in repeater item bound. like.

 chkSelectValue.Attributes.Add("onClick", "javascript:UncheckHeader('" + ViewState["chkHeaderSelect"].ToString() + "');");  -- for row check boxes in item and alternative item and for header its like--
ViewState["chkHeaderSelect"] = chkHeaderSelect.ClientID;
                    chkHeaderSelect.Attributes.Add("onClick", "javascript:CheckAll(this);");
in the header of the item bound


Friday, June 8, 2012

Finding the last friday of a month

Here is the code

 //// First we set the num of day add to 1.
        int addDay = 1;

        //// Getting today's date.
        DateTime d = DateTime.Today;

        //// tis loop will execute until the month changes to next.
        while (d.Month == DateTime.Today.Month)
        {
            DateTime friday;          

            //// Checks whether the date d is a friday or not.
            if (d.DayOfWeek == DayOfWeek.Friday)
            {
                friday = d.Date;

                //// From here we add 7 days to the date taken.
                //// It is used to reduce the loop count.
                //// Adding 7 days will result to the next friday.
                addDay = 7;
            }

            d = d.AddDays(addDay);
          }
Finaly the friday will contain the last friday date of the month.
Similarly you can find out other week days. Cheers...

3D Google Map

Google Inc is deploying a fleet of small, camera-equipped airplanes above several cities, the Internet search company’s latest step in its ambitious and sometimes controversial plan to create a digital map of the world.
Google plans to release the first three-dimensional maps for several cities by the end of the year, the company said at a news conference at its San Francisco offices on Wednesday. Google declined to name the cities, but it showed a demonstration of a 3D map of San Francisco, in which a user can navigate around an aerial view of the city.
“We’re trying to create the illusion that you’re just flying over the city, almost as if you were in your own personal helicopter,” said Peter Birch, a product manager for Google Earth.
Read more 

Thursday, June 7, 2012

DATEADD() SQL

 Syntax is : DATEADD(datepart,number,date)

Datepart are as follows
year
quarter
month
dayofyear
day
week
weekday
hour
minute
second
millisecond
microsecond
nanosecond

EG:

declare @d datetime
select @d=dateadd(day,1,getdate())

Transaction In SQL

We use Transaction in sql to avoid accidental data loss.
The keywords used are Begin Tran, Commit Tran, Rollback Tran.

Begin Tran - It is written in the beginning of the sql statements.
Commit Tran - Its is written after the sql statements.
Rollback Tran - It is executed if the user want to revert the changes.

EG:


BEGIN TRAN
UPDATE UiBaseTable
    SET
        Text          = 'Debrief Decision Saved successfully',
        TextKeyDescription    = 'Debrief Decision Saved successfully'
    WHERE
        TEXTKEY      = 'DebriefDecisionSaved'
       
GO

UPDATE UiBaseTable
    SET
        Text             = 'Country default saved successfully',
        TextKeyDescription    = 'Country default saved successfully'
    WHERE
        TEXTKEY   = 'SaveCountryDefault'   
           
GO

UPDATE UiBaseTable
    SET
        Text          = 'Vehicle Unreserved successfully',
        TextKeyDescription    = 'Vehicle Unreserved successfully'
    WHERE
        TEXTKEY       = 'VehicleUnReserved'

COMMIT TRAN

ROLLBACK TRAN

Here we are updating more than one statements. suppose i want to update all or nothing, so if any statement fails i can roll back the changes by executing  ROLLBACK TRAN.

Wednesday, June 6, 2012

Windows 8 Release Preview with IE10

We built a new browsing experience in lockstep with Windows 8 to give you all the advantages that Metro style apps offer. We built that experience by extending IE’s underlying architecture to provide a fast, fully hardware-accelerated browsing engine with strong security and support for HTML5 and other web standards.
Internet Explorer 10 is designed to make website interaction fast and fluid for touch as well as for heavy mouse and keyboard use. With IE10, websites participate in the Metro style experience in Windows 8, including the Start screen, charms, snap, and more. IE10 also provides the best protection from malicious software on the web while providing convenient control over your online privacy.
The Metro style browsing experience is a better way to browse on a desktop computer with a big screen, mouse and keyboard, or on a touch-enabled mobile device. As people browse more “chromelessly” on their phones, they’ve become accustomed to a more immersive and less manual browsing experience compared with the desktop. Metro style browsing offers you a full-screen, immersive site experience with every pixel of the screen for your favorite sites. With IE and Windows 8 you can always use the charms to accomplish what you want to do next with a website (e.g. share, print, search…). We’ve heard from many people – even those with the most enthusiastic and intense browsing patterns – prefer Metro style browsing because it’s fast, fluid and more focused on what you browse than on how you browse.

Connecting with IPv6 in Windows 8

IPv4 is the Internet Protocol that has been used for Internet connectivity for decades. However, IPv4 was never designed for such load and scale, and it is beginning to show signs of strain as the Internet grows—even though the incredible foresight of the original designers continues to power the Internet at a massive scale. Internet service providers are finding IPv4 increasingly costly to maintain; it will require an overhaul to sustain the upcoming onslaught of connected PCs and devices.
For several years, the industry, including Microsoft, has been working to roll out a completely new version of the Internet Protocol – IPv6 – across various devices, services, and network infrastructure. Windows releases since Windows XP SP3 have supported IPv6, making the IPv6 transition possible. We have engineered Windows 8 to keep you (and your apps) reliably connected as this dramatic transition takes place.
Read more 

Delivering the Windows 8 Release Preview

Today, Windows 8 Release Preview is available for download in 14 languages. This is our final pre-release, and includes Windows 8, Internet Explorer 10, new Windows 8 apps for connecting to Hotmail, SkyDrive, and Messenger (and many more), and hundreds of new and updated apps in the Windows Store. Since our first preview release last September, millions of people now use the pre-release product on a daily basis and millions more have been taking it through its paces, totaling hundreds of millions of hours of testing. We genuinely appreciate the effort that so many have put into pre-release testing, and of course, we appreciate the feedback too. Direct feedback and feedback through usage contributed to hundreds of visible changes in the product and tens of thousands of under-the-hood changes.
Read more 

Tuesday, June 5, 2012

Jquery Browser Detection

The command is $.browser.
Possible values:  
$.browser.webkit
$.browser.safari
$.browser.opera
$.browser.msie -- IE
$.browser.mozilla


Sample code


<script type="text/javascript">
    function ValidateSelect() {
        var brow = $.browser;
       
        var lblMessage = $('#<%=lblCloseAuctionValidation.ClientID%>');
        var message = '<%=CloseAuctionMessage%>';
        var IsExit = false;
       
        $('#ThirdpartyAuctionDiv input:radio:checked').each(function() {
            var value = $(this).val();
            if (value == 'AWAITINGDECISION') {
                IsExit = true;
            }
        });

        if (IsExit == false) {
            lblMessage.text('');
            var confirmMessage = '<%=ConfirmationMessage %>';
            if (confirm(confirmMessage) == false) {
           
                if (brow.msie == true) {
                    event.returnValue = false;
                }
                return false;
            }          
        }
        else {
            lblMessage.text(message);
           
            if (brow.msie == true) {
                event.returnValue = false;
            }
            return false;
        }
    }
</script>

Follow this blog

I personally invite you to join this blog and keep updated. You can join and follow this blog by clicking on the join button on the right side panel of the window.

IE 7/8 javascript Return false issue

I ve been working on js for last 2 days, but when i use return false in client side validation, the page went postback. Bt actually i want to prevent post back. Only IE 7/8 shows this problem. This issue was solved by
"event.returnValue = false;"


 if (confirm(confirmMessage) == false) {
                event.returnValue = false;
                return false;
            }
            else {
                return true;
            }


Friday, June 1, 2012

Windows 8 release

 Microsoft is nearly done with a much-anticipated overhaul of its Windows operating system.
The software maker signaled the makeover is nearly complete with Thursday’s release of the final test version of Windows 8.
Windows 8 is considered to be the biggest change in decades to Microsoft’s widely used operating system. The software displays applications in a mosaic of tiles and has been designed so it can run desktop, laptop and tablet computers.
PC sales have slowed in the U.S. as consumers delay replacements and instead buy mobile devices such as smartphones and tablet computers. The versatility of Windows 8 is expected to spawn a new generation of computers that are part laptop, part tablet.
Read More

Facebook reportedly drop their support to google chrome

Facebook has reportedly dropped their support for Google’s Chrome web browser, instead replacing it with Opera on their recommended browser list. The move could signal that a rumored acquisition of the browser maker is nearly complete.
When a user visits the social network using a browser that isn’t official supported, Facebook redirects them to a page that lists browsers they say will give users the best experience. Until recently, that list included Internet Explorer, Mozilla Firefox and Chrome. Observant viewers have since noticed that Chrome has been replaced by Opera in this list, although independent testing on my end with Chrome didn’t trigger the same browser warning that others are experiencing.

Read More