HttpCapabilitiesBase.RequiresContentTypeMetaTag 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
<meta>
특성이 지정된 HTML content-type
요소가 브라우저에 필요한지 여부를 나타내는 값을 가져옵니다.
public:
virtual property bool RequiresContentTypeMetaTag { bool get(); };
public virtual bool RequiresContentTypeMetaTag { get; }
member this.RequiresContentTypeMetaTag : bool
Public Overridable ReadOnly Property RequiresContentTypeMetaTag As Boolean
속성 값
브라우저에true
특성이 지정된 HTML <meta>
요소가 필요하면 content-type
이고, 필요하지 않으면 false
입니다. 기본값은 false
입니다.
예제
다음 코드 예제에서는 브라우저에 특성이 지정된 HTML <meta>
요소가 content-type
필요한지 여부를 확인하는 방법을 보여 줍니다.
<%@ page language="C#"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Load(Object Sender, EventArgs e)
{
CheckBrowserCaps();
}
void CheckBrowserCaps()
{
String labelText = "";
System.Web.HttpBrowserCapabilities myBrowserCaps = Request.Browser;
if (((System.Web.Configuration.HttpCapabilitiesBase)myBrowserCaps).RequiresContentTypeMetaTag)
{
labelText = "Browser requires an HTML META element whose CONTENT-TYPE attribute is specified.";
}
else
{
labelText = "Browser does not require an HTML META element whose CONTENT-TYPE attribute is specified.";
}
Label1.Text = labelText;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Browser Capabilities Sample</title>
</head>
<body>
<form runat="server" id="form1">
<div>
Browser Capabilities:
<p/><asp:Label ID="Label1" Runat="server" />
</div>
</form>
</body>
</html>
<%@ page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
CheckBrowserCaps()
End Sub
Function CheckBrowserCaps()
Dim labelText As String = ""
Dim myBrowserCaps As System.Web.HttpBrowserCapabilities = Request.Browser
If (CType(myBrowserCaps, System.Web.Configuration.HttpCapabilitiesBase)).RequiresContentTypeMetaTag Then
labelText = "Browser requires an HTML META element whose CONTENT-TYPE attribute is specified."
Else
labelText = "Browser does not require an HTML META element whose CONTENT-TYPE attribute is specified."
End If
Label1.Text = labelText
End Function 'CheckBrowserCaps
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Browser Capabilities Sample</title>
</head>
<body>
<form runat="server" id="form1">
<div>
Browser Capabilities:
<p/><asp:Label ID="Label1" Runat="server" />
</div>
</form>
</body>
</html>
설명
서버 제어 어댑터가 웹 페이지의 HTML <head>
요소에 다음 태그를 삽입하는 경우true
:
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT=""; CHARSET="">
이 예제 CONTENT
에서는 속성에서 반환되는 PreferredRenderingMime 값이며 charset
사용되는 문자 인코딩입니다.