静态局部刷新参考代码

function $(id) {
    if (id != null || id != "") {
        return document.getElementById(ClientIDPrefix + id);
    }
}

function Get() {

    if ($("txt").value == "") {
        $("lbl").value = "";
        return;
    }
    var xmlhttp;
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }
    else {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            var str = xmlhttp.responseText;
            $("lbl").value = str;
            $("lbl").title = str;
        }
    }
    xmlhttp.open("GET", location.href + "?txtNeirong=" + $("txt").value + "", true);
    xmlhttp.send();

}

以上是前台

下面是后台

 protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
        }
            Ajax();
        }
    }

 private void Ajax()
    {
        string str= Request["txtNeirong"] ?? "";
        if (!string.IsNullOrEmpty(str))
        {
                Response.Write(“lblNeirong”);
                Response.End();
        }
        else
        {
                Response.Write(string.Empty);
                Response.End();//????
        }
  }

 UpdatePanel?

 asp后台设置颜色?不刷新?

 

posted @ 2013-08-29 23:47  剑握在手  阅读(353)  评论(0编辑  收藏  举报
返回顶部↑