① aspx中嵌入后台处理代码,用<% %>
例1:
<div class="panel-body leftPbody">
???????????????????????????<div class="panel-group" id="accordion">
???????????????????????????????<% Response.Write(strListHtml); %>
???????????????????????????</div>
???????????????????????</div>
例2:
<span id="LPCourse_ID"><%=strCourse_ID%></span>
②在js中需要访问后台,借助ajax
function getAjax(url, parm, callBack) {
???$.ajax({
???????type: ‘post‘,
???????dataType: "text",
???????url: url,
???????data: parm,
???????cache: false,
???????async: false,
???????success: function (msg) {
???????????callBack(msg);
???????}
???});
}
function GetVideo(x, y) {
???var parm = ‘action=aaaa‘;
???parm = parm + ‘&A=‘ + x;
???getAjax(‘ashx/oo.ashx‘, parm, function (rs) {
???????try {
???????????if(rs=="")
???????????{
.......
???????????}
???????????else
???????????{
????????????????......
???????????}
ashx/oo.ashx:
public class oo: IHttpHandler, IRequiresSessionState
???{
???????public void ProcessRequest(HttpContext context)
???????{
???????????context.Response.ContentType = "text/plain";
???????????context.Response.Buffer = true;
???????????context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
???????????context.Response.AddHeader("pragma", "no-cache");
???????????context.Response.AddHeader("cache-control", "");
???????????context.Response.CacheControl = "no-cache";
???????????string Action = context.Request["action"]; ?//提交动作
???????????switch (Action)
???????????{
......
}
关于aspx,js前后台交互相关
原文地址:http://www.cnblogs.com/piaoyangguoguo/p/7976298.html