在javascript内部得到.cs页面的变量值。
html页面:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
<!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 type="text/javascript">
function aaa()
{
var v='<%=str %>';//可以得到后台页面的值
alert(v);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" type="button" value="button" onclick="aaa()"/></div>
</form>
</body>
</html>
cs页面:
public partial class Default4 : System.Web.UI.Page
{
public string str = "";
protected void Page_Load(object sender, EventArgs e)
{
str = "欢迎访问本页面";
}
}