【后台】
public string s="hello";
【前台】
alert(' <%=s%>');
代码实例:下面是一段分页的脚本代码,不过不提供分页功能只是呈现页数,页码,后台字段数据是:tpid,xm,pagecount,xcm
<script type="text/javascript">
var tpid = new Array();
var xm = new Array();
var j = 2;
tpids = "<%=tpid%>";
xms = "<%=xm%>";
pagecount = "<%=pagecount%>";
xcm = "<%=xcm%>";
tpid = tpids.split(",");
xm = xms.split(",");
document.write('<marquee width="100%" behavior="scroll" direction="left" align="middle" border="0px" scrolldelay="250px">欢迎你浏览 相册——'+xcm+'</marquee></div>');
document.write("<div id='page_1' style='display:block' >");
for (var i = 0; i < tpid.length; i++) {
document.write('<img class="imgsrc" src=Handler.ashx?ImID=' + tpid[i] + ' alt="' + xm[i] + '" />');
if ((i + 1) % 8 == 0 && i + 1 != pagecount) {
document.write('</div><div id=page_' + j + ' style="display:none" >');
j++;
}
}
document.write("</div>");
document.write("<div style='color: #fff; text-align:center' id='showys' >第1页,共" + pagecount + "页</div>");