当前位置: 代码迷 >> ASP.NET >> 怎么通过.ashx文件控制页面中DIV的显隐
  详细解决方案

怎么通过.ashx文件控制页面中DIV的显隐

热度:1228   发布时间:2013-02-25 00:00:00.0
如何通过.ashx文件控制页面中DIV的显隐?
我页面中有两个DIV
<div class="SubBody" style="width: 770px; margin-left: 9px;" id="ProductScheme">
<div class="SubBody1" visible="false" style="width: 770px; margin-left: 9px;" runat="server" id="BookingDemo">
其中第一个DIV中的内容是通过.ashx文件构建出来的,
$.ajax({
                url: "Ashx/GetProduct.ashx",
                type: "post",
                data:
                    {
                        pid: obj2
                    },
                dataType: "text",
                success: function (txt) {
                    $(".SubBody")(txt);
                }
            });
第二个DIV是在页面中写的,我想通过点击页面中的一个<a>标签,并将pid设置为1000,能否在.ashx中通过判断pid的值来控制第二个DIV的显示与隐藏啊

------最佳解决方案--------------------------------------------------------
你可以在.ashx文件中写一个方法啊,就判断pid的值,返回show或者hide。然后在$.ajax的success里面写
function(txt){
    if(txt=="show"){
        $("#BookingDemo").show();
    }
    else
        $("#BoolingDemo).hide();
}
------其他解决方案--------------------------------------------------------
写死

$.ajax({
  url: "Ashx/GetProduct.ashx",
  type: "post",
  data:
  {
  pid: 1000
  },
  dataType: "text",
  success: function (txt) {
  $(".SubBody1")(txt);
  }
  });

------其他解决方案--------------------------------------------------------
学习了,不过还是不明白