ASP.Net/Request/Browser Capabilities — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 11:53, 26 мая 2010

Browser support Java? (VB.net)

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    Dim BCaps As HttpBrowserCapabilities
    BCaps = Request.Browser
    lblMessage.Text = "Supports ActiveX Controls: " _
        & BCaps.ActiveXControls & "<BR>" _
        & "Supports Java Applets: " _
        & BCaps.JavaApplets & "<BR>" _
        & "Supports Java Script: " _
        & BCaps.JavaScript & "<BR>" _
        & "Supports VB Script: " _
        & BCaps.VBScript & "<BR>"
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Browser Code Capabilities</TITLE>
</HEAD>
<form runat="server">
<asp:label 
    id="lblMessage" 
    font-size="12pt"
    font-name="Tahoma"
    runat="server"
/>
</form>
</BODY>
</HTML>



Browser supports ActiveX Controls? (VB.net)

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    Dim BCaps As HttpBrowserCapabilities
    BCaps = Request.Browser
    lblMessage.Text = "Supports ActiveX Controls: " _
        & BCaps.ActiveXControls & "<BR>" _
        & "Supports Java Applets: " _
        & BCaps.JavaApplets & "<BR>" _
        & "Supports Java Script: " _
        & BCaps.JavaScript & "<BR>" _
        & "Supports VB Script: " _
        & BCaps.VBScript & "<BR>"
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Browser Code Capabilities</TITLE>
</HEAD>
<form runat="server">
<asp:label 
    id="lblMessage" 
    font-size="12pt"
    font-name="Tahoma"
    runat="server"
/>
</form>
</BODY>
</HTML>



Browser supports cookie? (VB.net)

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    Dim BCaps As HttpBrowserCapabilities
    BCaps = Request.Browser
    If BCaps.Cookies Then
        lblMessage.Text = "Your browser supports cookies!"
    Else
        lblMessage.Text = "You browser does not " _
            & "support cookies!"
    End If
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Browser Cookies</TITLE>
</HEAD>
<form runat="server">
<asp:label 
    id="lblMessage" 
    font-size="12pt"
    font-name="Tahoma"
    runat="server"
/>
</form>
</BODY>
</HTML>



Browser supports Javascript (VB.net)

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    Dim BCaps As HttpBrowserCapabilities
    BCaps = Request.Browser
    lblMessage.Text = "Supports ActiveX Controls: " _
        & BCaps.ActiveXControls & "<BR>" _
        & "Supports Java Applets: " _
        & BCaps.JavaApplets & "<BR>" _
        & "Supports Java Script: " _
        & BCaps.JavaScript & "<BR>" _
        & "Supports VB Script: " _
        & BCaps.VBScript & "<BR>"
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Browser Code Capabilities</TITLE>
</HEAD>
<form runat="server">
<asp:label 
    id="lblMessage" 
    font-size="12pt"
    font-name="Tahoma"
    runat="server"
/>
</form>
</BODY>
</HTML>



Browser support VB script (VB.net)

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    Dim BCaps As HttpBrowserCapabilities
    BCaps = Request.Browser
    lblMessage.Text = "Supports ActiveX Controls: " _
        & BCaps.ActiveXControls & "<BR>" _
        & "Supports Java Applets: " _
        & BCaps.JavaApplets & "<BR>" _
        & "Supports Java Script: " _
        & BCaps.JavaScript & "<BR>" _
        & "Supports VB Script: " _
        & BCaps.VBScript & "<BR>"
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Browser Code Capabilities</TITLE>
</HEAD>
<form runat="server">
<asp:label 
    id="lblMessage" 
    font-size="12pt"
    font-name="Tahoma"
    runat="server"
/>
</form>
</BODY>
</HTML>



Get Browser Name (VB.net)

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    Dim BCaps As HttpBrowserCapabilities
    BCaps = Request.Browser
    If BCaps.Browser = "IE" Then
        Response.Redirect("http://www.nfex.ru")
    ElseIf BCaps.Browser = "Netscape" Then
        Response.Redirect("http://www.nfex.ru")
    Else
        Response.Redirect("http://www.nfex.ru")
    End If
End Sub
</SCRIPT>



Http Browser Capabilities (VB.net)

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    Dim BCaps As HttpBrowserCapabilities
    BCaps = Request.Browser
    lblMessage1.Text = lblMessage1.Text _
        & "AOL: " & BCaps.AOL & "<BR>" _
        & "Supports BG Sounds: " & BCaps.BackgroundSounds & "<BR>" _
        & "Beta Browser: " & BCaps.Beta & "<BR>" _
        & "Browser Name: " & BCaps.Browser & "<BR>" _
        & "Supports Cookies: " & BCaps.Cookies & "<BR>" _
        & "Is a Web Crawler: " & BCaps.Crawler & "<BR>" _
        & "Browser Major Version: " & BCaps.MajorVersion & "<BR>" _
        & "Browser Minor Version: " & BCaps.MinorVersion & "<BR>" _
        & "Platform: " & BCaps.Platform & "<BR>" _
        & "Is Win 16: " & BCaps.Win16 & "<BR>" _
        & "Is Win 32: " & BCaps.Win32 & "<BR>" 
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Browser Capabilities Sample Page</TITLE>
</HEAD>
<BODY >
<form runat="server">
<Font Face="Tahoma">
<asp:Label
    id="lblMessage1"
    runat="Server"
    Font-Bold="True"
/>
</Font>
</Form>
</BODY>
</HTML>



Isits window based? (VB.net)

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    Dim BCaps As HttpBrowserCapabilities
    BCaps = Request.Browser
    lblMessage.Text = "Operating System: " _
        & BCaps.Platform & "<BR>" _
        & "Is OS Windows 16-bit based: " _
        & BCaps.Win16 & "<BR>" _
        & "Is OS Windows 32-bit based: " _
        & BCaps.Win32 & "<BR>" 
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Browser OS</TITLE>
</HEAD>
<form runat="server">
<asp:label 
    id="lblMessage" 
    font-size="12pt"
    font-name="Tahoma"
    runat="server"
/>
</form>
</BODY>
</HTML>