다음을 통해 공유


HtmlImage.Src 속성

정의

표시할 이미지 파일의 원본을 가져오거나 설정합니다.

public:
 property System::String ^ Src { System::String ^ get(); void set(System::String ^ value); };
public string Src { get; set; }
member this.Src : string with get, set
Public Property Src As String

속성 값

표시할 이미지 파일의 경로를 포함하는 문자열입니다.

예제

다음 코드 예제에서는 웹 페이지 소스 파일과 동일한 디렉터리에 표시할 이미지 파일을 지정 하는 속성을 사용 Src 하는 방법을 보여 줍니다.

<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
 <head>
    <title>HtmlImage Example</title>
</head>
 
 <body>
 
    <form id="form1" runat="server">
 
       <h3>HtmlImage Example</h3>
     
       <img id ="Image1"
            src="Image1.jpg"
            alt="Image 1"
            runat="server"
            style="width:500; height:226; border:5; text-align:center" />
    
    </form>
 
 </body>
 </html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
 <head>
    <title>HtmlImage Example</title>
</head>
 
 <body>
 
    <form id="form1" runat="server">
 
       <h3>HtmlImage Example</h3>
     
       <img id ="Image1"
            src="Image1.jpg"
            alt="Image 1"
            runat="server"
            style="width:500; height:226; border:5; text-align:center" />
    
    </form>
 
 </body>
 </html>

다음 코드 예제에서는 웹 페이지 소스 파일과 다른 디렉터리에 표시할 이미지 파일을 지정 하는 속성을 사용 Src 하는 방법을 보여 줍니다.

<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
 <head>
    <title>HtmlImage Example</title>
</head>
 
 <body>
 
    <form id="form1" runat="server">
 
       <h3>HtmlImage Example</h3>
     
       <img id ="Image1"
            src="Image1.jpg"
            alt="Image 1"
            runat="server"
            style="width:500; height:226; border:5; text-align:center" />
    
    </form>
 
 </body>
 </html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
 <head>
    <title>HtmlImage Example</title>
</head>
 
 <body>
 
    <form id="form1" runat="server">
 
       <h3>HtmlImage Example</h3>
     
       <img id ="Image1"
            src="Image1.jpg"
            alt="Image 1"
            runat="server"
            style="width:500; height:226; border:5; text-align:center" />
    
    </form>
 
 </body>
 </html>

설명

이 속성을 사용하여 표시할 이미지 파일의 경로를 지정합니다. 이미지 파일이 사용하는 웹 페이지 원본 파일과 동일한 디렉터리에 있는 경우 파일 이름을 지정할 수 있습니다. 그렇지 않으면 파일 경로도 포함해야 합니다. 경로는 절대 경로이거나 웹 페이지 원본 파일이 포함된 디렉터리를 기준으로 할 수 있습니다. 상대 경로 " " ~/ 를 사용하여 페이지가 있는 현재 가상 디렉터리를 참조할 수 있습니다. 예를 들어 "XspTest" 가상 디렉터리의 페이지에 대한 <img runat="server" src="~/abc/d.gif">Src 은 다음과 같습니다<img src="/XspText/abc/d.gif">.

적용 대상