Thursday, 18 October 2012

Detect the Operating System of the Client

 

Detect the Operating System of the Client System.

 

Here is technique to Detect the OS of the Client System and to execute particular codes based upon the detection. 

Design Part:


    <div>

        <asp:Label ID="Label1" runat="server" ForeColor="Red"></asp:Label>

        <br />

        <br />

        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />

    </div>


Code Behind:


        if (Request.UserAgent.IndexOf("Windows NT 5.1") > 0)

        {

             //Do this when the Client OS is XP

             Label1.Text="Welcome to XP.";

        }

        else if (Request.UserAgent.IndexOf("Windows NT 6.0") > 0)

        {

            //Do this when the Client OS is VISTA

            Label1.Text="Welcome to Vista.";

        }

        else if (Request.UserAgent.IndexOf("Windows NT 6.1") > 0)

        {

            //Do this when the Client OS is Windows 7

            Label1.Text="Welcome to Windows 7.";

        }

No comments:

Post a Comment

Thank You for Your Comments. We will get back to you soon.

back to top