제목 : 속성(Property)을 사용해서 자바스크립트에서 C# 결과값 사용
글번호:
|
|
319
|
작성자:
|
|
레드플러스
|
작성일:
|
|
2009/09/03 오후 11:05:00
|
조회수:
|
|
4839
|
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FrmJavaScriptWithProperty.aspx.cs" Inherits="FrmJavaScriptWithProperty" %>
<!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 runat="server">
<title>속성을 사용해서 자바스크립트에서 코드 비하인드의 값 사용하기</title>
<script language="javascript" type="text/javascript">
var str = "현재시간 : " + "<%= Now %>" + "";
window.alert(str);
function ShowImage(name) {
alert(name);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<img src='<%= ImageName %>' onmouseover='ShowImage("<%= ImageName %>")' />
</div>
</form>
</body>
</html>
using System;
public partial class FrmJavaScriptWithProperty : System.Web.UI.Page
{
private string _Now;
public string Now
{
get { return _Now; }
set { _Now = value; }
}
private string _ImageName;
public string ImageName
{
get { return _ImageName; }
set { _ImageName = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
_Now = DateTime.Now.ToString();
_ImageName = "Product01.jpg";
}
}