<script language="javascript" type="text/javascript">
function CallCSVariable() {
alert("<%= Str %>");
}
function CallCSMethod() {
alert('<%= GetStr("this is a ") %>');
}
</script>
<div>
<input id="Button1" type="button" value="访问C#变量" onclick="CallCSVariable();" />
<input id="Button2" type="button" value="调用C#方法" onclick="CallCSMethod();" />
</div>
//C#声明的变量
public string Str = "C# variable";
//C#声明的方法
public string GetStr(string str)
{
return str + Str;
}